예제 #1
0
        private void UpdateLabels(RadSize availableSize)
        {
            RadRect availableRect = new RadRect(availableSize.Width, availableSize.Height);
            RadRect ellipseRect   = RadRect.ToSquare(availableRect, false);

            ellipseRect = RadRect.CenterRect(ellipseRect, availableRect);
            double   radius = ellipseRect.Width / 2;
            RadPoint center = ellipseRect.Center;
            RadPoint arcPosition;

            foreach (AxisLabelModel label in this.owner.labels)
            {
                if (!label.isVisible)
                {
                    continue;
                }

                double angle = this.owner.IsInverse ? 360 - (double)label.normalizedPosition * 360 : (double)label.normalizedPosition * 360;
                arcPosition = RadMath.GetArcPoint(angle, center, radius);

                this.UpdateMargins(ellipseRect, label.desiredSize, arcPosition);
            }

            double offset = this.owner.LineThickness + this.owner.MajorTickLength;

            this.margins.Left   += offset;
            this.margins.Top    += offset;
            this.margins.Right  += offset;
            this.margins.Bottom += offset;
        }
예제 #2
0
        protected override RadRect ArrangeCore(RadRect rect)
        {
            double   radius = rect.Width / 2;
            RadPoint center = rect.Center;
            NumericalAxisPlotInfo polarPlot = this.firstPlotInfo as NumericalAxisPlotInfo;
            double       pointRadius        = polarPlot.NormalizedValue * radius;
            AxisPlotInfo anglePlot          = this.secondPlotInfo;

            this.angle = 0d;

            NumericalAxisPlotInfo numericalAnglePlot = anglePlot as NumericalAxisPlotInfo;

            if (numericalAnglePlot != null)
            {
                this.angle = numericalAnglePlot.ConvertToAngle();
            }
            else
            {
                CategoricalAxisPlotInfo categoricalAnglePlot = anglePlot as CategoricalAxisPlotInfo;
                if (categoricalAnglePlot != null)
                {
                    this.angle = categoricalAnglePlot.ConvertToAngle(this.GetChartArea <PolarChartAreaModel>());
                }
            }

            RadPoint arcPosition = RadMath.GetArcPoint(this.angle, center, pointRadius);
            RadSize  desiredSize = this.Measure();

            return(new RadRect(arcPosition.X, arcPosition.Y, desiredSize.Width, desiredSize.Height));
        }
        protected override RadRect ArrangeCore(RadRect rect)
        {
            double       radius    = rect.Width / 2;
            RadPoint     center    = rect.Center;
            AxisPlotInfo anglePlot = this.plotInfo;
            double       angle     = 0d;

            NumericalAxisPlotInfo numericalAnglePlot = anglePlot as NumericalAxisPlotInfo;

            if (numericalAnglePlot != null)
            {
                angle = numericalAnglePlot.ConvertToAngle();
            }
            else
            {
                CategoricalAxisPlotInfo categoricalAnglePlot = anglePlot as CategoricalAxisPlotInfo;
                if (categoricalAnglePlot != null)
                {
                    angle = categoricalAnglePlot.ConvertToAngle(this.GetChartArea <PolarChartAreaModel>());
                }
            }

            RadPoint arcPoint = RadMath.GetArcPoint(angle, center, radius);

            this.radialLine = new RadPolarVector()
            {
                Point = arcPoint, Angle = angle, Center = center
            };

            return(new RadRect(center, arcPoint));
        }
예제 #4
0
        protected override RadRect ArrangeCore(RadRect rect)
        {
            this.radius = rect.Width / 2;
            RadPoint center = rect.Center;

            AxisPlotInfo anglePlot1 = this.firstPlotInfo;
            double       angle1     = 0d;

            NumericalAxisPlotInfo numericalAnglePlot1 = anglePlot1 as NumericalAxisPlotInfo;

            if (numericalAnglePlot1 != null)
            {
                angle1 = numericalAnglePlot1.ConvertToAngle();
            }
            else
            {
                CategoricalAxisPlotInfo categoricalAnglePlot1 = anglePlot1 as CategoricalAxisPlotInfo;
                if (categoricalAnglePlot1 != null)
                {
                    angle1 = categoricalAnglePlot1.ConvertToAngle(this.GetChartArea <PolarChartAreaModel>());
                }
            }

            RadPoint arcPoint1 = RadMath.GetArcPoint(angle1, center, this.radius);

            this.polarVector1 = new RadPolarVector()
            {
                Point = arcPoint1, Angle = angle1, Center = center
            };

            AxisPlotInfo anglePlot2 = this.secondPlotInfo;
            double       angle2     = 0d;

            NumericalAxisPlotInfo numericalAnglePlot2 = anglePlot2 as NumericalAxisPlotInfo;

            if (numericalAnglePlot2 != null)
            {
                angle2 = numericalAnglePlot2.ConvertToAngle();
            }
            else
            {
                CategoricalAxisPlotInfo categoricalAnglePlot2 = anglePlot2 as CategoricalAxisPlotInfo;
                if (categoricalAnglePlot2 != null)
                {
                    angle2 = categoricalAnglePlot2.ConvertToAngle(this.GetChartArea <PolarChartAreaModel>());
                }
            }

            RadPoint arcPoint2 = RadMath.GetArcPoint(angle2, center, this.radius);

            this.polarVector2 = new RadPolarVector()
            {
                Point = arcPoint2, Angle = angle2, Center = center
            };

            return(rect);
        }
예제 #5
0
        public static Geometry RenderArc(DoughnutSegmentData context)
        {
            PathFigure figure = new PathFigure();

            figure.IsClosed = true;
            figure.IsFilled = true;

            RadPoint startPoint = RadMath.GetArcPoint(context.StartAngle, context.Center, context.Radius1);

            figure.StartPoint = startPoint.ToPoint();

            ArcSegment firstArc = new ArcSegment();

            firstArc.Size       = new Size(context.Radius1, context.Radius1);
            firstArc.IsLargeArc = context.SweepAngle > 180 || context.SweepAngle < -180;

            var angle = context.StartAngle;

            if (context.SweepDirection == SweepDirection.Clockwise)
            {
                angle += context.SweepAngle;
            }
            else
            {
                angle -= context.SweepAngle;
            }

            firstArc.SweepDirection = context.SweepAngle > 0 ? context.SweepDirection : context.SweepDirection ^ SweepDirection.Clockwise;

            firstArc.Point = RadMath.GetArcPoint(angle, context.Center, context.Radius1).ToPoint();
            figure.Segments.Add(firstArc);

            LineSegment firstLine = new LineSegment();

            firstLine.Point = RadMath.GetArcPoint(angle, context.Center, context.Radius2).ToPoint();
            figure.Segments.Add(firstLine);

            ArcSegment secondArc = new ArcSegment();

            secondArc.Size           = new Size(context.Radius2, context.Radius2);
            secondArc.IsLargeArc     = context.SweepAngle > 180 || context.SweepAngle < -180;
            secondArc.SweepDirection = context.SweepAngle > 0 ? context.SweepDirection ^ SweepDirection.Clockwise : context.SweepDirection;
            secondArc.Point          = RadMath.GetArcPoint(context.StartAngle, context.Center, context.Radius2).ToPoint();
            figure.Segments.Add(secondArc);

            PathGeometry geometry = new PathGeometry();

            geometry.Figures.Add(figure);

            return(geometry);
        }
예제 #6
0
        internal override void UpdateAxisLine(ChartLayoutContext context)
        {
            PolarChartAreaModel chartArea = this.chart.chartArea as PolarChartAreaModel;
            double   angle  = chartArea.NormalizeAngle(0);
            RadPoint center = chartArea.plotArea.layoutSlot.Center;
            RadPoint point  = RadMath.GetArcPoint(angle, center, chartArea.plotArea.layoutSlot.Width / 2);

            double antiAliasOffset = this.model.LineThickness % 2 == 1 ? 0.5 : 0;

            this.line.X1 = center.X;
            this.line.Y1 = center.Y - antiAliasOffset;
            this.line.X2 = point.X;
            this.line.Y2 = point.Y - antiAliasOffset;

            base.UpdateAxisLine(context);
        }
예제 #7
0
        private PathGeometry BuildPolarStripe(RadPolarVector vector, RadPolarVector nextVector, bool isLargeArc)
        {
            RadPoint center = this.model.layoutSlot.Center;
            double   radius = this.model.layoutSlot.Width / 2;

            double endAngle = nextVector.Angle;

            if (endAngle == 360)
            {
                endAngle = 0;
            }
            RadPoint arcEndPoint = RadMath.GetArcPoint(endAngle, center, radius);

            PathGeometry geometry = new PathGeometry();
            PathFigure   figure   = new PathFigure();

            figure.IsClosed = true;
            figure.IsFilled = true;

            figure.StartPoint = new Point(vector.Center.X, vector.Center.Y);

            // first line
            figure.Segments.Add(new LineSegment()
            {
                Point = new Point(vector.Point.X, vector.Point.Y)
            });

            // arc
            ArcSegment arc = new ArcSegment();

            arc.SweepDirection = (this.Chart as RadPolarChart).RadialAxis.SweepDirection;
            arc.Size           = new Size(radius, radius);
            arc.IsLargeArc     = isLargeArc;
            arc.Point          = new Point(arcEndPoint.X, arcEndPoint.Y);
            figure.Segments.Add(arc);

            // second line
            figure.Segments.Add(new LineSegment()
            {
                Point = new Point(nextVector.Point.X, nextVector.Point.Y)
            });

            geometry.Figures.Add(figure);

            return(geometry);
        }
예제 #8
0
        internal override void Arrange(RadRect availableRect)
        {
            double   thickness  = this.owner.TickThickness;
            double   startAngle = this.StartAngle;
            double   radius     = availableRect.Width / 2;
            RadPoint center     = availableRect.Center;

            double   length          = this.owner.MajorTickLength;
            RadPoint labelAxisCenter = RadMath.GetArcPoint(startAngle + 90, center, length * 2);

            double angleInRad = (360 - startAngle) * RadMath.DegToRadFactor;
            double sin        = Math.Sin(angleInRad);
            double cos        = Math.Cos(angleInRad);

            foreach (AxisTickModel tick in this.owner.ticks)
            {
                double   tickRadius   = (double)tick.normalizedValue * radius;
                double   tickLength   = this.owner.GetTickLength(tick);
                RadPoint tickPosition = RadMath.GetArcPoint(startAngle, center, tickRadius);
                tick.Arrange(new RadRect(tickPosition.X, tickPosition.Y, thickness, tickLength));

                if (tick.associatedLabel == null)
                {
                    continue;
                }

                RadSize desiredSize = tick.associatedLabel.desiredSize;
                double  halfWidth   = desiredSize.Width / 2;
                double  halfHeight  = desiredSize.Height / 2;

                RadPoint labelPosition = RadMath.GetArcPoint(startAngle, labelAxisCenter, tickRadius);
                RadRect  bounds        = new RadRect(labelPosition.X - halfWidth, labelPosition.Y - halfHeight, desiredSize.Width, desiredSize.Height);

                bounds.X += sin * halfWidth;
                bounds.Y += cos * halfHeight;

                tick.associatedLabel.Arrange(bounds);
            }
        }
예제 #9
0
        internal override void Arrange(RadRect availableRect)
        {
            var polarArea = this.owner.GetChartArea <PolarChartAreaModel>();

            RadRect tickRect  = this.GetTicksArrangeRect(availableRect);
            RadRect labelRect = this.GetLabelsArrangeRect(tickRect);

            RadPoint tickCenter = tickRect.Center;
            double   tickRadius = tickRect.Width / 2;

            RadPoint labelCenter = labelRect.Center;
            double   labelRadius = labelRect.Width / 2;

            double tickThickness = this.owner.TickThickness;

            foreach (AxisTickModel tick in this.owner.ticks)
            {
                if (!tick.isVisible)
                {
                    continue;
                }

                double   angle        = polarArea.NormalizeAngle((double)tick.value);
                RadPoint tickPosition = RadMath.GetArcPoint(angle, tickCenter, tickRadius);
                tick.Arrange(new RadRect(tickPosition.X, tickPosition.Y, tickThickness, this.owner.GetTickLength(tick)));

                if (tick.associatedLabel == null || !tick.associatedLabel.isVisible)
                {
                    continue;
                }

                RadSize  desiredSize   = tick.associatedLabel.desiredSize;
                RadPoint labelPosition = RadMath.GetArcPoint(angle, labelCenter, labelRadius);
                labelPosition.X += desiredSize.Width * Math.Cos(angle * RadMath.DegToRadFactor) / 2;
                labelPosition.Y += desiredSize.Height * Math.Sin(angle * RadMath.DegToRadFactor) / 2;
                tick.associatedLabel.Arrange(new RadRect(labelPosition.X - (desiredSize.Width / 2), labelPosition.Y - (desiredSize.Height / 2), desiredSize.Width, desiredSize.Height));
            }
        }
예제 #10
0
        internal override RadPoint ConvertDataToPoint(Tuple <object, object> data)
        {
            var pointRadius = double.NaN;

            if (this.primaryFirstAxis != null && this.primaryFirstAxis.isUpdated)
            {
                NumericalAxisPlotInfo plotInfo = this.primaryFirstAxis.CreatePlotInfo(data.Item1) as NumericalAxisPlotInfo;
                if (plotInfo != null)
                {
                    double radius = this.plotArea.layoutSlot.Width / 2;
                    pointRadius = plotInfo.NormalizedValue * radius;
                }
            }

            var pointAngle = double.NaN;

            if (this.primarySecondAxis != null && this.primarySecondAxis.isUpdated)
            {
                if (this.primarySecondAxis is CategoricalAxisModel)
                {
                    CategoricalAxisPlotInfo categoricalPlotInfo = this.primarySecondAxis.CreatePlotInfo(data.Item2) as CategoricalAxisPlotInfo;
                    if (categoricalPlotInfo != null)
                    {
                        pointAngle = categoricalPlotInfo.ConvertToAngle(this);
                    }
                }
                else
                {
                    NumericalAxisPlotInfo numericalPlotInfo = this.primarySecondAxis.CreatePlotInfo(data.Item2) as NumericalAxisPlotInfo;
                    if (numericalPlotInfo != null)
                    {
                        pointAngle = numericalPlotInfo.ConvertToAngle();
                    }
                }
            }

            return(RadMath.GetArcPoint(pointAngle, this.plotArea.layoutSlot.Center, pointRadius));
        }
예제 #11
0
        internal override RadRect ArrangeOverride(RadRect rect)
        {
            double   radius = rect.Width / 2;
            RadPoint arcPosition;
            RadPoint center = rect.Center;

            foreach (CategoricalDataPoint point in this.DataPoints)
            {
                if (point.numericalPlot == null || point.categoricalPlot == null)
                {
                    continue;
                }

                double pointRadius = point.numericalPlot.NormalizedValue * radius;
                double angle       = point.categoricalPlot.ConvertToAngle(this.GetChartArea() as PolarChartAreaModel);
                arcPosition = RadMath.GetArcPoint(angle, center, pointRadius);

                RadSize pointSize = point.Measure();
                point.Arrange(new RadRect(arcPosition.X - (pointSize.Width / 2), arcPosition.Y - (pointSize.Height / 2), pointSize.Width, pointSize.Height), false);
            }

            return(rect);
        }