public void SnapPointToGridLine(CategoricalDataPoint point)
        {
            if (point.numericalPlot == null)
            {
                return;
            }

            if (point.numericalPlot.SnapTickIndex < 0 ||
                point.numericalPlot.SnapTickIndex >= point.numericalPlot.Axis.ticks.Count)
            {
                return;
            }

            AxisTickModel tick = point.numericalPlot.Axis.ticks[point.numericalPlot.SnapTickIndex];

            if (!RadMath.AreClose(point.numericalPlot.NormalizedValue, (double)tick.normalizedValue))
            {
                return;
            }

            if (this.PlotDirection == AxisPlotDirection.Vertical)
            {
                CategoricalSeriesRoundLayoutContext.SnapToGridLineVertical(point, tick.layoutSlot);
            }
            else
            {
                CategoricalSeriesRoundLayoutContext.SnapToGridLineHorizontal(point, tick.layoutSlot);
            }
        }
Exemple #2
0
        internal override void ApplyLayoutRounding()
        {
            CategoricalSeriesRoundLayoutContext info = new CategoricalSeriesRoundLayoutContext(this);

            double            gapLength = CategoricalAxisModel.DefaultGapLength;
            ISupportGapLength axisModel = this.firstAxis as ISupportGapLength;

            if (axisModel == null)
            {
                axisModel = this.secondAxis as ISupportGapLength;
            }

            if (axisModel != null)
            {
                gapLength = axisModel.GapLength;
            }

            int count = this.DataPointsInternal.Count;

            foreach (CategoricalDataPoint point in this.DataPointsInternal)
            {
                info.SnapPointToPlotLine(point);
                info.SnapPointToGridLine(point);

                if (gapLength == 0 && point.CollectionIndex < count - 1)
                {
                    DataPoint nextPoint = this.DataPointsInternal[point.CollectionIndex + 1];
                    info.SnapToAdjacentPointInHistogramScenario(point, nextPoint);
                }
            }
        }
        private static void ApplyLayoutRoundingVertical(CombinedSeries series, CategoricalSeriesRoundLayoutContext info)
        {
            double previousStackRight = -1;
            CategoricalDataPoint firstPoint;
            CategoricalDataPoint point;
            CategoricalDataPoint previousPositivePoint = null;
            CategoricalDataPoint previousNegativePoint = null;

            foreach (CombineGroup group in series.Groups)
            {
                foreach (CombineStack stack in group.Stacks)
                {
                    // first point is on the plot line
                    firstPoint = stack.Points[0] as CategoricalDataPoint;
                    if (previousStackRight != -1)
                    {
                        firstPoint.layoutSlot.X = previousStackRight;
                    }
                    info.SnapPointToPlotLine(firstPoint);
                    info.SnapPointToGridLine(firstPoint);

                    int count = stack.Points.Count;
                    previousPositivePoint = firstPoint;
                    previousNegativePoint = firstPoint;

                    for (int i = 1; i < count; i++)
                    {
                        point = stack.Points[i] as CategoricalDataPoint;

                        if (point.numericalPlot == null || double.IsNaN(point.layoutSlot.Center.X) || double.IsNaN(point.layoutSlot.Center.Y))
                        {
                            continue;
                        }

                        if (previousStackRight != -1)
                        {
                            point.layoutSlot.X = previousStackRight;
                        }

                        //// inverse axis with negative point is equivalent to regular axis with positive point
                        if (point.isPositive ^ point.numericalPlot.Axis.IsInverse)
                        {
                            point.layoutSlot.Y    = previousPositivePoint.layoutSlot.Y - point.layoutSlot.Height;
                            previousPositivePoint = point;
                        }
                        else
                        {
                            point.layoutSlot.Y    = previousNegativePoint.layoutSlot.Bottom;
                            previousNegativePoint = point;
                        }
                        info.SnapPointToGridLine(point);
                    }

                    previousStackRight = firstPoint.isEmpty ? -1 : firstPoint.layoutSlot.Right;
                }

                previousStackRight = -1;
            }
        }
        public override void ApplyLayoutRounding(ChartAreaModel chart, CombinedSeries series)
        {
            CategoricalSeriesModel categoricalSeries = series.Series[0] as CategoricalSeriesModel;

            if (categoricalSeries == null)
            {
                Debug.Assert(false, "Invalid combined series.");
                return;
            }

            CategoricalSeriesRoundLayoutContext info = new CategoricalSeriesRoundLayoutContext(categoricalSeries);

            if (info.PlotDirection == AxisPlotDirection.Vertical)
            {
                ApplyLayoutRoundingVertical(series, info);
            }
            else
            {
                ApplyLayoutRoundingHorizontal(series, info);
            }
        }