internal void Update(PieDataPoint dataPoint, PieUpdateContext context) { this.UpdateCore(dataPoint, context); this.point = dataPoint; // tag is used for hit-testing purposes this.Path.Tag = dataPoint; }
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); }
/// <summary> /// Updates of all of the chart elements presented by this instance. /// </summary> internal override void UpdateUICore(ChartLayoutContext context) { if (this.renderSurface == null) { return; } RadSize availableSize = new RadSize( this.chart.chartArea.layoutSlot.Width * this.chart.zoomCache.Width, this.chart.chartArea.layoutSlot.Height * this.chart.zoomCache.Height); this.updateContext = this.GetUpdateContext(availableSize); this.UpdateSegments(); base.UpdateUICore(context); }
internal void BuildArc(PieDataPoint dataPoint, PieUpdateContext updateContext) { if (this.figure == null) { return; } Point originalCenter = updateContext.Center; updateContext.Center = GetCenterPointWithOffset(dataPoint, updateContext); this.figure.StartPoint = updateContext.Center; this.UpdateHighlightPath(dataPoint, updateContext); // first line LineSegment line1 = new LineSegment(); line1.Point = updateContext.CalculateArcPoint(updateContext.StartAngle); this.figure.Segments.Add(line1); // arc ArcSegment arc = new ArcSegment(); arc.IsLargeArc = dataPoint.SweepAngle > 180 || dataPoint.SweepAngle < -180; arc.Size = updateContext.ArcSize; arc.SweepDirection = dataPoint.SweepAngle > 0 ? updateContext.SweepDirection : updateContext.SweepDirection ^ SweepDirection.Clockwise; // advance the starting angle if (updateContext.SweepDirection == SweepDirection.Clockwise) { updateContext.StartAngle += dataPoint.SweepAngle; } else { updateContext.StartAngle -= dataPoint.SweepAngle; } arc.Point = updateContext.CalculateArcPoint(updateContext.StartAngle); this.figure.Segments.Add(arc); // second line LineSegment line2 = new LineSegment(); line2.Point = updateContext.Center; this.figure.Segments.Add(line2); updateContext.Center = originalCenter; }
protected virtual void UpdateCore(PieDataPoint dataPoint, PieUpdateContext context) { if (this.figure != null) { this.figure.Segments.Clear(); if (dataPoint.SweepAngle >= ArcSegmentMaxAngle) { this.AddEllipse(context); } else { this.BuildArc(dataPoint, context); } dataPoint.Radius = context.Radius; dataPoint.CenterPoint = context.Center; } }
internal static Point GetCenterPointWithOffset(PieDataPoint dataPoint, PieUpdateContext context) { double offset = dataPoint.OffsetFromCenter; if (offset == 0) { return(context.Center); } double pixelOffset = (int)(context.Radius * offset); double originalRadius = context.Radius; context.Radius = pixelOffset; Point centerWithOffset = context.CalculateArcPoint(context.StartAngle + (dataPoint.sweepAngle / 2)); context.Radius = originalRadius; return(centerWithOffset); }
private void AddEllipse(PieUpdateContext context) { this.figure.StartPoint = context.CalculateArcPoint(0); ArcSegment arc = new ArcSegment(); arc.IsLargeArc = true; arc.Size = context.ArcSize; arc.SweepDirection = SweepDirection.Clockwise; arc.Point = context.CalculateArcPoint(180); this.figure.Segments.Add(arc); arc = new ArcSegment(); arc.IsLargeArc = true; arc.Size = context.ArcSize; arc.SweepDirection = SweepDirection.Clockwise; arc.Point = context.CalculateArcPoint(360); // update the highlight path EllipseGeometry outerEllipse = new EllipseGeometry(); outerEllipse.RadiusX = context.Radius; outerEllipse.RadiusY = context.Radius; outerEllipse.Center = context.Center; EllipseGeometry innerEllipse = new EllipseGeometry(); innerEllipse.RadiusX = context.Radius * this.ParentSeries.HighlightInnerRadiusFactor; innerEllipse.RadiusY = context.Radius * this.ParentSeries.HighlightInnerRadiusFactor; innerEllipse.Center = context.Center; GeometryGroup data = new GeometryGroup(); data.Children.Add(outerEllipse); data.Children.Add(innerEllipse); this.highlightPath.Data = data; this.figure.Segments.Add(arc); }
protected override void UpdateCore(PieDataPoint dataPoint, PieUpdateContext context) { var doughnutContext = context as DoughnutUpdateContext; if (doughnutContext != null) { var segmentData = DoughnutSegment.GetSegmentData(dataPoint, doughnutContext); var highlightSegmentData = DoughnutSegment.GetSegmentData(dataPoint, doughnutContext); highlightSegmentData.Radius2 = 0.9 * context.Radius; if (context.SweepDirection == SweepDirection.Clockwise) { context.StartAngle += dataPoint.SweepAngle; } else { context.StartAngle -= dataPoint.SweepAngle; } this.Path.Data = DoughnutSegmentRenderer.Render(dataPoint, segmentData); this.HighlightPath.Data = DoughnutSegmentRenderer.Render(dataPoint, highlightSegmentData); var doughnutPoint = dataPoint as DoughnutDataPoint; if (doughnutPoint != null) { doughnutPoint.Radius = doughnutContext.Radius; doughnutPoint.InnerRadius = doughnutContext.Radius * doughnutContext.InnerRadiusFactor; doughnutPoint.CenterPoint = doughnutContext.Center; } } else { base.UpdateCore(dataPoint, context); } }
internal virtual PieUpdateContext SetupUpdateContext(RadSize availableSize, Size updatedAvailableSize, PieUpdateContext context) { context.Diameter = Math.Min(updatedAvailableSize.Width, updatedAvailableSize.Height) * this.RadiusFactor; context.Radius = context.Diameter / 2; // Adding 0.5 to exceed the integer part of the double. That way after cast to int will return the same result as round operation. // This solution is used since it is faster. context.Center = new Point( (int)(((availableSize.Width - updatedAvailableSize.Width) / 2) + (updatedAvailableSize.Width / 2) + .5), (int)(((availableSize.Height - updatedAvailableSize.Height) / 2) + (updatedAvailableSize.Height / 2) + .5)); context.StartAngle = this.model.Range.StartAngle; context.ArcSize = new Size(context.Radius, context.Radius); context.SweepDirection = (SweepDirection)this.AngleRange.SweepDirection; return(context); }
internal override PieUpdateContext SetupUpdateContext(RadSize availableSize, Size updatedAvailableSize, PieUpdateContext context) { var doghnutContext = base.SetupUpdateContext(availableSize, updatedAvailableSize, context) as DoughnutUpdateContext; if (context != null) { doghnutContext.InnerRadiusFactor = this.InnerRadiusFactor; } return(doghnutContext); }