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);
            }
        }
        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;
            }
        }
 internal void SnapToAdjacentPointInHistogramScenario(CategoricalDataPoint point, DataPoint nextPoint)
 {
     // TODO: Fix histogram bars in scenarios with combination (multiple bar series)
     // NOTE: We intentionally overlap the bar layout slots with single pixel so the border of the visual does not get blurred.
     if (this.PlotDirection == AxisPlotDirection.Vertical)
     {
         point.layoutSlot.Width = nextPoint.layoutSlot.X - point.layoutSlot.X + 1;
     }
     else
     {
         nextPoint.layoutSlot.Height = point.layoutSlot.Y - nextPoint.layoutSlot.Y + 1;
     }
 }
        public void SnapPointToPlotLine(CategoricalDataPoint point)
        {
            if (point.numericalPlot == null)
            {
                return;
            }

            if (this.PlotDirection == AxisPlotDirection.Vertical)
            {
                // positive point with regular axis is equivalent to negative point with inverse axis
                if (point.isPositive ^ point.numericalPlot.Axis.IsInverse)
                {
                    point.layoutSlot.Y = this.PlotLine - point.layoutSlot.Height;
                    if (this.PlotOrigin > 0)
                    {
                        point.layoutSlot.Y++;
                    }
                }
                else
                {
                    point.layoutSlot.Y = this.PlotLine;
                }
            }
            else
            {
                // positive point with regular axis is equivalent to negative point with inverse axis
                if (point.isPositive ^ point.numericalPlot.Axis.IsInverse)
                {
                    point.layoutSlot.X = this.PlotLine;
                }
                else
                {
                    point.layoutSlot.X = this.PlotLine - point.layoutSlot.Width;
                    if (this.PlotOrigin < 1)
                    {
                        point.layoutSlot.X++;
                    }
                }
            }
        }
        private static void SnapToGridLineVertical(CategoricalDataPoint point, RadRect tickRect)
        {
            double difference;
            double gridLine = tickRect.Y + (int)(tickRect.Height / 2);

            // positive point with regular axis is equivalent to negative point with inverse axis
            if (point.isPositive ^ point.numericalPlot.Axis.IsInverse)
            {
                difference               = point.layoutSlot.Y - gridLine;
                point.layoutSlot.Y      -= difference;
                point.layoutSlot.Height += difference;
            }
            else
            {
                difference = gridLine - point.layoutSlot.Bottom;
                point.layoutSlot.Height += difference + 1;
            }

            if (point.layoutSlot.Height < 0)
            {
                point.layoutSlot.Height = 0;
            }
        }
        private static void SnapToGridLineHorizontal(CategoricalDataPoint point, RadRect tickRect)
        {
            double difference;
            double gridLine = tickRect.X + (int)(tickRect.Width / 2);

            // positive point with regular axis is equivalent to negative point with inverse axis
            if (point.isPositive ^ point.numericalPlot.Axis.IsInverse)
            {
                difference              = point.layoutSlot.Right - gridLine;
                point.layoutSlot.Width -= difference - 1;
            }
            else
            {
                difference              = gridLine - point.layoutSlot.X;
                point.layoutSlot.X     += difference;
                point.layoutSlot.Width -= difference;
            }

            if (point.layoutSlot.Width < 0)
            {
                point.layoutSlot.Width = 0;
            }
        }
Ejemplo n.º 7
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.LayoutRoot = ((System.Windows.Controls.Grid)(target));
                return;

            case 2:
                this.a01 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 3:
                this.a02 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 4:
                this.a03 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 5:
                this.a04 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 6:
                this.a05 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 7:
                this.a06 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 8:
                this.a07 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 9:
                this.a08 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 10:
                this.a09 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 11:
                this.b01 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 12:
                this.b02 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 13:
                this.b03 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 14:
                this.b04 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 15:
                this.b05 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 16:
                this.b06 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 17:
                this.b07 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 18:
                this.b08 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;

            case 19:
                this.b09 = ((Telerik.Charting.CategoricalDataPoint)(target));
                return;
            }
            this._contentLoaded = true;
        }