Esempio n. 1
0
        /// <summary>
        /// Collect statistical information about the series.
        /// </summary>
        /// <param name="segmentCount">Segment count.</param>
        /// <param name="minYValue">Minimum Y value.</param>
        /// <param name="maxYValue">Maximum Y value.</param>
        /// <param name="segmentSize">Segment size.</param>
        /// <param name="segmentMaxValue">Array of segment scale maximum values.</param>
        /// <param name="segmentMinValue">Array of segment scale minimum values.</param>
        /// <returns></returns>
        internal int[] GetSeriesDataStatistics(
            int segmentCount,
            out double minYValue,
            out double maxYValue,
            out double segmentSize,
            out double[] segmentMaxValue,
            out double[] segmentMinValue)
        {
            // Get all series associated with the axis
            ArrayList axisSeries = AxisScaleBreakStyle.GetAxisSeries(this.axis);

            // Get range of Y values from axis series
            minYValue = 0.0;
            maxYValue = 0.0;
            axis.Common.DataManager.GetMinMaxYValue(axisSeries, out minYValue, out maxYValue);

            int numberOfPoints = 0;

            foreach (Series series in axisSeries)
            {
                numberOfPoints = Math.Max(numberOfPoints, series.Points.Count);
            }

            if (axisSeries.Count == 0 || numberOfPoints == 0)
            {
                segmentSize     = 0.0;
                segmentMaxValue = null;
                segmentMinValue = null;
                return(null);
            }

            // Split range of values into predefined number of segments and calculate
            // how many points will be in each segment.
            segmentSize = (maxYValue - minYValue) / segmentCount;
            int[] segmentPointNumber = new int[segmentCount];
            segmentMaxValue = new double[segmentCount];
            segmentMinValue = new double[segmentCount];
            for (int index = 0; index < segmentCount; index++)
            {
                segmentMaxValue[index] = double.NaN;
                segmentMinValue[index] = double.NaN;
            }
            foreach (Series series in axisSeries)
            {
                // Get number of Y values to process
                int        maxYValueCount = 1;
                IChartType chartType      = this.axis.ChartArea.Common.ChartTypeRegistry.GetChartType(series.ChartTypeName);
                if (chartType != null)
                {
                    if (chartType.ExtraYValuesConnectedToYAxis && chartType.YValuesPerPoint > 1)
                    {
                        maxYValueCount = chartType.YValuesPerPoint;
                    }
                }

                // Iterate throug all data points
                foreach (DataPoint dataPoint in series.Points)
                {
                    if (!dataPoint.IsEmpty)
                    {
                        // Iterate through all yValues
                        for (int yValueIndex = 0; yValueIndex < maxYValueCount; yValueIndex++)
                        {
                            // Calculate index of the scale segment
                            int segmentIndex = (int)Math.Floor((dataPoint.YValues[yValueIndex] - minYValue) / segmentSize);
                            if (segmentIndex < 0)
                            {
                                segmentIndex = 0;
                            }
                            if (segmentIndex > segmentCount - 1)
                            {
                                segmentIndex = segmentCount - 1;
                            }

                            // Increase number points in that segment
                            ++segmentPointNumber[segmentIndex];

                            // Store Min/Max values for the segment
                            if (segmentPointNumber[segmentIndex] == 1)
                            {
                                segmentMaxValue[segmentIndex] = dataPoint.YValues[yValueIndex];
                                segmentMinValue[segmentIndex] = dataPoint.YValues[yValueIndex];
                            }
                            else
                            {
                                segmentMaxValue[segmentIndex] = Math.Max(segmentMaxValue[segmentIndex], dataPoint.YValues[yValueIndex]);
                                segmentMinValue[segmentIndex] = Math.Min(segmentMinValue[segmentIndex], dataPoint.YValues[yValueIndex]);
                            }
                        }
                    }
                }
            }

            return(segmentPointNumber);
        }
Esempio n. 2
0
        /// <summary>
        /// Checks if scale breaks can be used on specified axis.
        /// </summary>
        /// <returns>True if scale breaks can be used on this axis</returns>
        internal bool CanUseAxisScaleBreaks()
        {
            // Check input parameters
            if (this.axis == null || this.axis.ChartArea == null || this.axis.ChartArea.Common.Chart == null)
            {
                return(false);
            }

            // No scale breaks in 3D charts
            if (this.axis.ChartArea.Area3DStyle.Enable3D)
            {
                return(false);
            }

            // Axis scale break can only be applied to the Y and Y 2 axis
            if (this.axis.axisType == AxisName.X || this.axis.axisType == AxisName.X2)
            {
                return(false);
            }

            // No scale breaks for logarithmic axis
            if (this.axis.IsLogarithmic)
            {
                return(false);
            }

            // No scale breaks if axis zooming is enabled
            if (this.axis.ScaleView.IsZoomed)
            {
                return(false);
            }

            // Check series associated with this axis
            ArrayList axisSeries = AxisScaleBreakStyle.GetAxisSeries(this.axis);

            foreach (Series series in axisSeries)
            {
                // Some special chart type are not supported
                if (series.ChartType == SeriesChartType.Renko ||
                    series.ChartType == SeriesChartType.PointAndFigure)
                {
                    return(false);
                }


                // Get chart type interface
                IChartType chartType = this.axis.ChartArea.Common.ChartTypeRegistry.GetChartType(series.ChartTypeName);
                if (chartType == null)
                {
                    return(false);
                }

                // Circular and stacked chart types can not use scale breaks
                if (chartType.CircularChartArea ||
                    chartType.Stacked ||
                    !chartType.RequireAxes)
                {
                    return(false);
                }
            }

            return(true);
        }