public static Geometry RenderEllipse(DoughnutSegmentData context) { var centerPoint = new Point(context.Center.X, context.Center.Y); EllipseGeometry outerEllipse = new EllipseGeometry(); outerEllipse.RadiusX = context.Radius1; outerEllipse.RadiusY = context.Radius1; outerEllipse.Center = centerPoint; EllipseGeometry innerEllipse = new EllipseGeometry(); double innerRadius = context.Radius2; innerEllipse.RadiusX = innerRadius; innerEllipse.RadiusY = innerRadius; innerEllipse.Center = centerPoint; GeometryGroup data = new GeometryGroup(); data.Children.Add(outerEllipse); data.Children.Add(innerEllipse); return(data); }
public static Geometry Render(PieDataPoint dataPoint, DoughnutSegmentData context) { if (dataPoint.SweepAngle >= ArcSegmentMaxAngle) { return(RenderEllipse(context)); } else { return(RenderArc(context)); } }
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); }
private void UpdateHighlightPath(PieDataPoint dataPoint, PieUpdateContext updateContext) { DoughnutSegmentData segment = new DoughnutSegmentData() { Center = new RadPoint(updateContext.Center.X, updateContext.Center.Y), Radius1 = updateContext.Radius, Radius2 = updateContext.Radius * this.ParentSeries.HighlightInnerRadiusFactor, StartAngle = updateContext.StartAngle, SweepAngle = dataPoint.SweepAngle, SweepDirection = updateContext.SweepDirection }; this.highlightPath.Data = DoughnutSegmentRenderer.Render(dataPoint, segment); }
private static Geometry BuildRadialStripe(RadCircle circle, RadCircle previousCircle) { DoughnutSegmentData segment = new DoughnutSegmentData() { Center = new RadPoint(circle.Center.X + 0.5, circle.Center.Y + 0.5), Radius1 = circle.Radius + 0.5, Radius2 = previousCircle.Radius - 0.5, StartAngle = 0, SweepAngle = 359.99 // 360 does not render properly }; if (segment.Radius1 < 0) { segment.Radius1 = 0; } if (segment.Radius2 < 0) { segment.Radius2 = 0; } return(DoughnutSegmentRenderer.RenderArc(segment)); }