Exemple #1
0
        internal override void ArrangeLabel(FrameworkElement visual, ChartSeriesLabelUpdateContext context)
        {
            RadSize      size     = MeasureVisual(visual);
            PieDataPoint piePoint = context.Point as PieDataPoint;

            double radius           = this.updateContext.Radius;
            double offsetFromCenter = radius * piePoint.OffsetFromCenter;
            double offset           = context.Definition.Margin.Left;

            // calculate the position of the label, depending on its size
            this.updateContext.Radius     = radius - offset + offsetFromCenter;
            this.updateContext.StartAngle = piePoint.startAngle;

            double angle = piePoint.startAngle;

            if (this.AngleRange.SweepDirection == ChartSweepDirection.Clockwise)
            {
                angle += piePoint.sweepAngle / 2;
            }
            else
            {
                angle -= piePoint.sweepAngle / 2;
            }

            Point middlePoint = this.updateContext.CalculateArcPoint(angle);

            middlePoint.X += size.Width * Math.Cos(angle * RadMath.DegToRadFactor) / 2;
            middlePoint.Y += size.Height * Math.Sin(angle * RadMath.DegToRadFactor) / 2;

            RadRect labelRect = RadRect.Round(new RadRect(middlePoint.X - (size.Width / 2), middlePoint.Y - (size.Height / 2), size.Width, size.Height));

            this.ArrangeUIElement(visual, labelRect);

            this.updateContext.Radius = radius;
        }
Exemple #2
0
        internal override void ArrangeTicks()
        {
            double x, y, lineHeight;
            double tickLength    = this.owner.tickSize.Width;
            double tickThickness = this.owner.tickSize.Height;

            if (this.owner.TickPlacementCache == ScaleElementPlacement.TopLeft)
            {
                x = this.owner.Line.X1 - (this.owner.LineThicknessCache / 2) - tickLength;
            }
            else if (this.owner.TickPlacementCache == ScaleElementPlacement.Center)
            {
                double fix = (tickLength % 2 == 0 && this.owner.LineThicknessCache % 2 == 1) ? 1 : 0;
                x = this.owner.Line.X1 - ((tickLength + fix) / 2);
            }
            else
            {
                x = this.owner.Line.X1 + (this.owner.LineThicknessCache / 2);
            }

            lineHeight = this.owner.Line.Y2 - this.owner.Line.Y1;

            foreach (var tick in this.owner.Ticks)
            {
                y = this.owner.Line.Y2 - tickThickness / 2.0 - (double)(tick.normalizedValue * (decimal)lineHeight);
                tick.layoutSlot = RadRect.Round(new RadRect(x, y, tickLength, tickThickness));
            }
        }
Exemple #3
0
        private static RadRect CalculatePlotAreaRect(RadRect availableRect, AxisStack leftStack, AxisStack topStack, AxisStack rightStack, AxisStack bottomStack)
        {
            RadPoint topLeft = new RadPoint();

            double finalLeftRectWidth = leftStack.desiredWidth + leftStack.desiredMargin.Left + leftStack.desiredMargin.Right;
            double maxLeftMargin      = Math.Max(topStack.desiredMargin.Left, bottomStack.desiredMargin.Left);

            topLeft.X = Math.Max(finalLeftRectWidth, maxLeftMargin);

            double finalTopRectHeight = topStack.desiredHeight + topStack.desiredMargin.Top + topStack.desiredMargin.Bottom;
            double maxTopMargin       = Math.Max(leftStack.desiredMargin.Top, rightStack.desiredMargin.Top);

            topLeft.Y = Math.Max(finalTopRectHeight, maxTopMargin);

            RadPoint bottomRight = new RadPoint();

            double finalRightRectWidth = rightStack.desiredWidth + rightStack.desiredMargin.Left + rightStack.desiredMargin.Right;
            double maxRightMargin      = Math.Max(topStack.desiredMargin.Right, bottomStack.desiredMargin.Right);

            bottomRight.X = availableRect.Width - Math.Max(finalRightRectWidth, maxRightMargin);

            double finalBottomRectHeight = bottomStack.desiredHeight + bottomStack.desiredMargin.Top + bottomStack.desiredMargin.Bottom;
            double maxBottomMargin       = Math.Max(leftStack.desiredMargin.Bottom, rightStack.desiredMargin.Bottom);

            bottomRight.Y = availableRect.Height - Math.Max(finalBottomRectHeight, maxBottomMargin);

            RadRect plotAreaRect = new RadRect(topLeft, bottomRight);

            return(RadRect.Round(plotAreaRect));
        }
        protected virtual bool ShouldPlotPoint(DataPoint point)
        {
            var pointBounds = RadRect.Round(point.layoutSlot);
            var plotBounds  = this.model.layoutSlot;

            var isWithinXPlot = pointBounds.X <= plotBounds.X + plotBounds.Width && pointBounds.X + pointBounds.Width >= plotBounds.X;
            var isWithinYPlot = pointBounds.Y <= plotBounds.Y + plotBounds.Height && pointBounds.Y + pointBounds.Height >= plotBounds.Y;

            if (isWithinXPlot && isWithinYPlot)
            {
                return(true);
            }

            var plotDirection = this.model.GetTypedValue <AxisPlotDirection>(AxisModel.PlotDirectionPropertyKey, AxisPlotDirection.Vertical);

            // empty values
            return((isWithinXPlot && double.IsNaN(point.layoutSlot.Y) && plotDirection == AxisPlotDirection.Vertical) ||
                   (isWithinYPlot && double.IsNaN(point.layoutSlot.X) && plotDirection == AxisPlotDirection.Horizontal));
        }