示例#1
0
        public void SnapPointToGridLine(RangeDataPoint point)
        {
            if (point.numericalPlot.SnapTickIndex >= 0 && point.numericalPlot.SnapTickIndex < point.numericalPlot.Axis.ticks.Count)
            {
                AxisTickModel highTick = point.numericalPlot.Axis.ticks[point.numericalPlot.SnapTickIndex];
                if (RadMath.AreClose(point.numericalPlot.NormalizedHigh, (double)highTick.normalizedValue))
                {
                    if (this.PlotDirection == AxisPlotDirection.Vertical)
                    {
                        SnapHighToVerticalGridLine(point, highTick.layoutSlot);
                    }
                    else
                    {
                        SnapHighToHorizontalGridLine(point, highTick.layoutSlot);
                    }
                }
            }

            if (point.numericalPlot.SnapBaseTickIndex >= 0 && point.numericalPlot.SnapBaseTickIndex < point.numericalPlot.Axis.ticks.Count)
            {
                AxisTickModel lowTick = point.numericalPlot.Axis.ticks[point.numericalPlot.SnapBaseTickIndex];
                if (RadMath.AreClose(point.numericalPlot.NormalizedLow, (double)lowTick.normalizedValue))
                {
                    if (this.PlotDirection == AxisPlotDirection.Vertical)
                    {
                        SnapLowToVerticalGridLine(point, lowTick.layoutSlot);
                    }
                    else
                    {
                        SnapLowToHorizontalGridLine(point, lowTick.layoutSlot);
                    }
                }
            }
        }
        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 void BuildYStripes(AxisModel yAxis, RadRect rect)
        {
            double height;
            double thickness       = yAxis.TickThickness;
            double thicknessOffset = (int)(thickness / 2);

            int plotOriginX = (int)(this.GetChartArea().view.PlotOriginX *rect.Width);
            int plotOriginY = (int)(this.GetChartArea().view.PlotOriginY *rect.Height);

            foreach (AxisTickModel tick in yAxis.MajorTicks)
            {
                AxisTickModel nextMajor = tick.NextMajorTick;
                if (nextMajor == null)
                {
                    break;
                }

                height = Math.Abs(tick.layoutSlot.Y - nextMajor.layoutSlot.Y);
                var top = yAxis.IsInverse ? nextMajor.layoutSlot.Y : tick.layoutSlot.Y;

                GridStripe stripe = new GridStripe();
                stripe.BorderRect     = new RadRect(rect.X, top + plotOriginY - height + thicknessOffset, rect.Width, height);
                stripe.FillRect       = new RadRect(rect.X, top + plotOriginY - height + thickness, rect.Width, height - thickness);
                stripe.AssociatedTick = tick;

                this.yStripes.Add(stripe);
            }
        }
        private void BuildXStripes(AxisModel xAxis, RadRect rect)
        {
            double width;
            double thickness       = xAxis.TickThickness;
            double thicknessOffset = (int)(thickness / 2);

            int plotOriginX = (int)(this.GetChartArea().view.PlotOriginX *rect.Width);
            int plotOriginY = (int)(this.GetChartArea().view.PlotOriginY *rect.Height);

            foreach (AxisTickModel tick in xAxis.MajorTicks)
            {
                AxisTickModel nextMajor = tick.NextMajorTick;
                if (nextMajor == null)
                {
                    break;
                }

                width = Math.Abs(nextMajor.layoutSlot.X - tick.layoutSlot.X);
                var        right  = xAxis.IsInverse ? nextMajor.layoutSlot.X : tick.layoutSlot.X;
                GridStripe stripe = new GridStripe();
                stripe.BorderRect     = new RadRect(right + plotOriginX + thicknessOffset, rect.Y, width, rect.Height);
                stripe.FillRect       = new RadRect(right + plotOriginY + thicknessOffset + thickness, rect.Y, width - thickness, rect.Height);
                stripe.AssociatedTick = tick;

                this.xStripes.Add(stripe);
            }
        }
        internal override object GetLabelContent(AxisTickModel tick)
        {
            if (tick.virtualIndex >= this.categories.Count)
            {
                return(null);
            }

            return(this.categories[tick.virtualIndex].KeySource);
        }
示例#6
0
        protected override bool BuildTicksAndLabels(RadSize availableSize)
        {
            bool result = base.BuildTicksAndLabels(availableSize);

            // last tick and label should not be visible
            AxisTickModel lastTick = this.LastTick;

            if (lastTick != null)
            {
                lastTick.isVisible = false;
                if (lastTick.associatedLabel != null)
                {
                    lastTick.associatedLabel.isVisible = false;
                }
            }

            return(result);
        }
示例#7
0
        private void UpdateTicks()
        {
            this.majorTickCount = 0;
            AxisTickModel previous   = null;
            int           tickIndex  = 0;
            int           startIndex = this.MajorTickOffset;

            foreach (AxisTickModel tick in this.GenerateTicks(this.visibleRange))
            {
                // consider tick offset
                if (tickIndex < startIndex)
                {
                    tickIndex++;
                    continue;
                }

                tick.position = TickPosition.Inner;
                this.ticks.Add(tick);
                tick.previous = previous;

                if (previous != null)
                {
                    previous.next = tick;
                }

                previous = tick;
                if (tick.Type == TickType.Major)
                {
                    this.majorTickCount++;
                }
            }

            if (this.ticks.Count > 0)
            {
                this.ticks[0].position = TickPosition.First;
            }
            if (this.ticks.Count > 1)
            {
                this.ticks[this.ticks.Count - 1].position = TickPosition.Last;
            }
        }
示例#8
0
        internal override void ApplyLayoutRounding()
        {
            // fit first and last ticks within axis layout slot
            AxisTickModel firstTick = this.owner.FirstTick;
            AxisTickModel lastTick  = this.owner.LastTick;

            double thickness       = this.owner.TickThickness;
            double thicknessOffset = (int)(thickness / 2);

            if (firstTick != null && RadMath.IsZero(firstTick.normalizedValue))
            {
                firstTick.layoutSlot.X = this.owner.layoutSlot.X - thicknessOffset;
            }
            if (lastTick != null && RadMath.IsOne(lastTick.normalizedValue))
            {
                double zoomWidth = this.owner.layoutSlot.Width * this.owner.GetChartArea().view.ZoomWidth;
                lastTick.layoutSlot.X = this.owner.layoutSlot.X + zoomWidth - thicknessOffset;

                // remove one additional pixel on the right (rendering along the X-axis goes from left to right)
                lastTick.layoutSlot.X--;
            }
        }
示例#9
0
        internal override void ApplyLayoutRounding()
        {
            // fit first and last ticks within axis layout slot
            AxisTickModel firstTick = this.owner.FirstTick;
            AxisTickModel lastTick  = this.owner.LastTick;

            double thickness       = this.owner.TickThickness;
            double thicknessOffset = (int)(thickness / 2);

            // ensure that the first and last ticks are within axis' layout slot
            if (firstTick != null && RadMath.IsZero(firstTick.normalizedValue))
            {
                double zoomHeight = this.owner.layoutSlot.Height * this.owner.GetChartArea().view.ZoomHeight;
                firstTick.layoutSlot.Y = this.owner.layoutSlot.Y + zoomHeight - thicknessOffset;

                // remove one additional pixel at bottom (rendering along the Y-axis goes from top to bottom)
                firstTick.layoutSlot.Y--;
            }
            if (lastTick != null && RadMath.IsOne(lastTick.normalizedValue))
            {
                lastTick.layoutSlot.Y = this.owner.layoutSlot.Y - thicknessOffset;
            }
        }
示例#10
0
 internal override object GetLabelContent(AxisTickModel tick)
 {
     return(new DateTime((long)tick.value));
 }
示例#11
0
 internal virtual double GetTickLength(AxisTickModel tick)
 {
     return(this.MajorTickLength);
 }
示例#12
0
 internal virtual object GetLabelContent(AxisTickModel tick)
 {
     return(tick.value);
 }