示例#1
0
        /// <summary>
        /// Set the X-axis with a specific type of ChartAxis.
        /// If successful, assigns the Axis type (x,y) and label position to the axis.
        /// </summary>
        /// <param name="labelPosition"></param>
        /// <param name="axis"></param>
        /// <param name="axisWidth"></param>
        /// <param name="axisLabelAngle"></param>
        public void SetXAxis(ElementPosition labelPosition, AbstractScaleAxis <TXAxisDataType> axis, AxisWidth axisWidth, int axisLabelAngle = 0)
        {
            if ((axisLabelAngle != 0) && (axisLabelAngle != 90))
            {
                throw new ArgumentException("AxisLabelAngle can only be 0 or 90.");
            }

            // Will throw an ArgumentException if it doesn't work.
            ValidateAxis(Axis.X, labelPosition);

            // Apply the requested value
            axis.AxisXY       = Axis.X;
            axis.AxisPosition = labelPosition;
            axis.AxisWidth    = axisWidth;
            axis.LabelAngle   = axisLabelAngle;
            _xAxis1           = axis;

            // If BOTH the Minimum or Maximum haven't been set, then auto-calculate values.
            if (EqualityComparer <TXAxisDataType> .Default.Equals(axis.MinimumValue, default) &&
                EqualityComparer <TXAxisDataType> .Default.Equals(axis.MaximumValue, default))
            {
                (TXAxisDataType Min, TXAxisDataType Max) = GetXAxisBounds();
                axis.MinimumValue = Min;
                axis.MaximumValue = Max;
            }
            Console.WriteLine($"For X axis min is {axis.MinimumValue} and max is {axis.MaximumValue}");

            axis.InitialAxisPreparation();
        }
示例#2
0
        /// <summary>
        /// Set the X-axis with a specific type of ChartAxis.
        /// If successful, assigns the Axis type (x,y) and label position to the axis.
        /// </summary>
        /// <param name="labelPosition"></param>
        /// <param name="axis"></param>
        /// <param name="axisWidth"></param>
        public void SetY1Axis(ElementPosition labelPosition, AbstractScaleAxis <TYAxisDataType> axis, AxisWidth axisWidth)
        {
            // Will throw an ArgumentException if it doesn't work.
            ValidateAxis(Axis.Y, labelPosition);

            // Apply the requested value
            axis.AxisXY       = Axis.Y;
            axis.AxisPosition = labelPosition;
            axis.AxisWidth    = axisWidth;
            _yAxis            = axis;

            // If BOTH the Minimum or Maximum haven't been set, then auto-calculate values.
            if (EqualityComparer <TYAxisDataType> .Default.Equals(axis.MinimumValue, default) &&
                EqualityComparer <TYAxisDataType> .Default.Equals(axis.MaximumValue, default))
            {
                (TYAxisDataType Min, TYAxisDataType Max) = GetYAxisBounds();
                axis.MinimumValue = Min;
                axis.MaximumValue = Max;
            }

            axis.InitialAxisPreparation();
        }