Beispiel #1
0
        /// <summary>
        /// Returns a pie in a canvas
        /// </summary>
        /// <param name="faces">Pie faces</param>
        /// <param name="pieParams">Pie parameters</param>
        /// <param name="unExplodedPoints">UnExploded dataPoints</param>
        /// <param name="explodedPoints">Exploded dataPoints</param>
        /// <param name="labelLinePath">Label line path</param>
        /// <param name="enabledDataPoints">List of enabled dataPoints</param>
        /// <returns>Canvas</returns>
        private static Canvas GetPie2D(DataSeries currentDataSeries, ref Faces faces, SectorChartShapeParams pieParams, ref PieDoughnut2DPoints unExplodedPoints, ref PieDoughnut2DPoints explodedPoints, ref Path labelLinePath, List<DataPoint> enabledDataPoints)
        {
            var noOfNonZeroDataPoint = (from dp in enabledDataPoints where dp.InternalYValue != 0 select dp);

            Canvas visual = new Canvas();

            Double width = pieParams.OuterRadius * 2;
            Double height = pieParams.OuterRadius * 2;

            visual.Width = width;
            visual.Height = height;

            Point center = new Point(width / 2, height / 2);
            Double xOffset = pieParams.OuterRadius * pieParams.ExplodeRatio * Math.Cos(pieParams.MeanAngle);
            Double yOffset = pieParams.OuterRadius * pieParams.ExplodeRatio * Math.Sin(pieParams.MeanAngle);

            #region PieSlice

            if (pieParams.StartAngle != pieParams.StopAngle || !pieParams.IsZero)
            {
                Ellipse ellipse = new Ellipse() { Tag = new ElementData() { Element = pieParams.TagReference } };
                ellipse.Width = width;
                ellipse.Height = height;
                ellipse.Fill = pieParams.Lighting ? Graphics.GetLightingEnabledBrush(pieParams.Background, "Radial", new Double[] { 0.99, 0.745 }) : pieParams.Background;

                Point start = new Point();
                Point end = new Point();
                Point arcMidPoint = new Point();

                start.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StartAngle);
                start.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StartAngle);

                end.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StopAngle);
                end.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StopAngle);

                arcMidPoint.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.MeanAngle);
                arcMidPoint.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.MeanAngle);

                List<PathGeometryParams> clipPathGeometry = new List<PathGeometryParams>();
                clipPathGeometry.Add(new LineSegmentParams(start));
                clipPathGeometry.Add(new ArcSegmentParams(new Size(pieParams.OuterRadius, pieParams.OuterRadius), 0, ((pieParams.StopAngle - pieParams.StartAngle) > Math.PI) ? true : false, SweepDirection.Clockwise, pieParams.AnimationEnabled ? start : arcMidPoint));
                clipPathGeometry.Add(new ArcSegmentParams(new Size(pieParams.OuterRadius, pieParams.OuterRadius), 0, ((pieParams.StopAngle - pieParams.StartAngle) > Math.PI) ? true : false, SweepDirection.Clockwise, pieParams.AnimationEnabled ? start : end));
                clipPathGeometry.Add(new LineSegmentParams(center));
                ellipse.Clip = GetPathGeometryFromList(FillRule.Nonzero, center, clipPathGeometry, true);
                PathSegmentCollection segments = (ellipse.Clip as PathGeometry).Figures[0].Segments;

                // apply animation to the individual points that for the pie slice
                if (pieParams.AnimationEnabled)
                {
                    // apply animation to the points
                    pieParams.Storyboard = CreatePathSegmentAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[1], center, pieParams.OuterRadius, currentDataSeries.InternalStartAngle, pieParams.MeanAngle);
                    pieParams.Storyboard = CreatePathSegmentAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[2], center, pieParams.OuterRadius, currentDataSeries.InternalStartAngle, pieParams.StopAngle);
                    pieParams.Storyboard = CreatePathSegmentAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[0], center, pieParams.OuterRadius, currentDataSeries.InternalStartAngle, pieParams.StartAngle);
                }

                faces.Parts.Add(ellipse);
                visual.Children.Add(ellipse);

                // set the un exploded points for interactivity
                unExplodedPoints.Center = center;
                unExplodedPoints.OuterArcStart = start;
                unExplodedPoints.OuterArcMid = arcMidPoint;
                unExplodedPoints.OuterArcEnd = end;

                // set the exploded points for interactivity
                explodedPoints.Center = new Point(center.X + xOffset, center.Y + yOffset);
                explodedPoints.OuterArcStart = new Point(start.X + xOffset, start.Y + yOffset);
                explodedPoints.OuterArcMid = new Point(arcMidPoint.X + xOffset, arcMidPoint.Y + yOffset);
                explodedPoints.OuterArcEnd = new Point(end.X + xOffset, end.Y + yOffset);

                if (enabledDataPoints.Count == 1 || noOfNonZeroDataPoint.Count() == 1)
                {
                    Ellipse borderEllipse = new Ellipse() { IsHitTestVisible = false, Height = ellipse.Height, Width = ellipse.Width };
                    borderEllipse.SetValue(Canvas.ZIndexProperty, (Int32)10000);
                    visual.Children.Add(borderEllipse);
                    faces.BorderElements.Add(borderEllipse);
                }
            }

            #endregion PieSlice

            #region Lighting

            if ((pieParams.TagReference as DataPoint).InternalYValue != 0 && pieParams.Lighting && (pieParams.StartAngle != pieParams.StopAngle || !pieParams.IsZero))
            {
                Ellipse lightingEllipse = new Ellipse() { Tag = new ElementData() { Element = pieParams.TagReference } };
                lightingEllipse.Width = width;
                lightingEllipse.Height = height;
                lightingEllipse.IsHitTestVisible = false;
                lightingEllipse.Fill = GetPieGradianceBrush();

                Point start = new Point();
                Point end = new Point();
                Point arcMidPoint = new Point();

                start.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StartAngle);
                start.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StartAngle);

                end.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StopAngle);
                end.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StopAngle);

                arcMidPoint.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.MeanAngle);
                arcMidPoint.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.MeanAngle);

                List<PathGeometryParams> clipPathGeometry = new List<PathGeometryParams>();
                clipPathGeometry.Add(new LineSegmentParams(start));
                clipPathGeometry.Add(new ArcSegmentParams(new Size(pieParams.OuterRadius, pieParams.OuterRadius), 0, ((pieParams.StopAngle - pieParams.StartAngle) > Math.PI) ? true : false, SweepDirection.Clockwise, pieParams.AnimationEnabled ? start : arcMidPoint));
                clipPathGeometry.Add(new ArcSegmentParams(new Size(pieParams.OuterRadius, pieParams.OuterRadius), 0, ((pieParams.StopAngle - pieParams.StartAngle) > Math.PI) ? true : false, SweepDirection.Clockwise, pieParams.AnimationEnabled ? start : end));
                clipPathGeometry.Add(new LineSegmentParams(center));
                lightingEllipse.Clip = GetPathGeometryFromList(FillRule.Nonzero, center, clipPathGeometry, true);
                PathSegmentCollection segments = (lightingEllipse.Clip as PathGeometry).Figures[0].Segments;

                // apply animation to the individual points that for the shape that
                // gives the lighting effect to the pie slice
                if (pieParams.AnimationEnabled)
                {
                    // apply animation to the points
                    pieParams.Storyboard = CreatePathSegmentAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[1], center, pieParams.OuterRadius, currentDataSeries.InternalStartAngle, pieParams.MeanAngle);
                    pieParams.Storyboard = CreatePathSegmentAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[2], center, pieParams.OuterRadius, currentDataSeries.InternalStartAngle, pieParams.StopAngle);
                    pieParams.Storyboard = CreatePathSegmentAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[0], center, pieParams.OuterRadius, currentDataSeries.InternalStartAngle, pieParams.StartAngle);
                }
                visual.Children.Add(lightingEllipse);
            }

            #endregion Lighting

            #region LabelLine

            if (pieParams.LabelLineEnabled)
            {
                Path labelLine = new Path() { Tag = new ElementData() { Element = pieParams.TagReference } };
                Double meanAngle = pieParams.MeanAngle;
                labelLine.SetValue(Canvas.ZIndexProperty, -100000);
                Point piePoint = new Point();
                piePoint.X = center.X + pieParams.OuterRadius * Math.Cos(meanAngle);
                piePoint.Y = center.Y + pieParams.OuterRadius * Math.Sin(meanAngle);

                Point labelPoint = new Point();
                labelPoint.X = center.X + pieParams.LabelPoint.X - pieParams.Width / 2;
                labelPoint.Y = center.Y + pieParams.LabelPoint.Y - pieParams.Height / 2;

                Point midPoint = new Point();
                // midPoint.X = (labelPoint.X < center.X) ? labelPoint.X + 10 : labelPoint.X - 10;
                if (pieParams.LabelLineTargetToRight)
                    midPoint.X = labelPoint.X + 10;
                else
                    midPoint.X = labelPoint.X - 10;

                midPoint.Y = labelPoint.Y;


                List<PathGeometryParams> labelLinePathGeometry = new List<PathGeometryParams>();
                labelLinePathGeometry.Add(new LineSegmentParams(pieParams.AnimationEnabled ? piePoint : midPoint));
                labelLinePathGeometry.Add(new LineSegmentParams(pieParams.AnimationEnabled ? piePoint : labelPoint));
                labelLine.Data = GetPathGeometryFromList(FillRule.Nonzero, piePoint, labelLinePathGeometry, true);
                PathFigure figure = (labelLine.Data as PathGeometry).Figures[0];
                PathSegmentCollection segments = figure.Segments;
                figure.IsClosed = false;
                figure.IsFilled = false;

                // animate the label lines of the individual pie slices
                if (pieParams.AnimationEnabled)
                {
                    pieParams.Storyboard = CreateLabelLineAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[0], piePoint, midPoint);
                    pieParams.Storyboard = CreateLabelLineAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[1], piePoint, midPoint, labelPoint);
                }

                labelLine.Stroke = pieParams.LabelLineColor;
                labelLine.StrokeDashArray = pieParams.LabelLineStyle;
                labelLine.StrokeThickness = pieParams.LabelLineThickness;

                labelLinePath = labelLine;

                if ((pieParams.TagReference as DataPoint).InternalYValue == 0)
                {
                    Line zeroLine = new Line();
                    zeroLine.X1 = center.X;
                    zeroLine.Y1 = center.Y;

                    zeroLine.X2 = piePoint.X;
                    zeroLine.Y2 = piePoint.Y;
                    zeroLine.Stroke = pieParams.LabelLineColor;
                    zeroLine.StrokeThickness = 0.25;
                    zeroLine.IsHitTestVisible = false;
                    visual.Children.Add(zeroLine);

                    if (pieParams.AnimationEnabled)
                    {
                        pieParams.Storyboard = CreateOpacityAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, zeroLine, 2, zeroLine.Opacity, 0.5);
                        zeroLine.Opacity = 0;
                    }
                }

                visual.Children.Add(labelLine);

                // set the un exploded points for interactivity
                unExplodedPoints.LabelLineEndPoint = labelPoint;
                unExplodedPoints.LabelLineMidPoint = midPoint;
                unExplodedPoints.LabelLineStartPoint = piePoint;

                // set the exploded points for interactivity
                explodedPoints.LabelLineEndPoint = new Point(labelPoint.X, labelPoint.Y - yOffset);
                explodedPoints.LabelLineMidPoint = new Point(midPoint.X, midPoint.Y - yOffset);
                explodedPoints.LabelLineStartPoint = new Point(piePoint.X + xOffset, piePoint.Y + yOffset);

                if ((pieParams.TagReference as DataPoint).InternalYValue == 0)
                    labelLine.IsHitTestVisible = false;
            }

            #endregion LabelLine

            #region Create path for selecting a pie section

            Point startPoint = new Point();
            Point endPoint = new Point();

            startPoint.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StartAngle);
            startPoint.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StartAngle);

            endPoint.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StopAngle);
            endPoint.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StopAngle);

            List<PathGeometryParams> pathGeometry = new List<PathGeometryParams>();
            pathGeometry.Add(new LineSegmentParams(center));
            pathGeometry.Add(new LineSegmentParams(startPoint));
            pathGeometry.Add(new ArcSegmentParams(new Size(pieParams.OuterRadius, pieParams.OuterRadius), 0, pieParams.IsLargerArc, SweepDirection.Clockwise, endPoint));

            if ((pieParams.TagReference as DataPoint).InternalYValue != 0)
            {
                Path p = new Path() { IsHitTestVisible = false };
                p.SetValue(Canvas.ZIndexProperty, (Int32)10000);
                p.Data = GetPathGeometryFromList(FillRule.Nonzero, center, pathGeometry, true);
                visual.Children.Add(p);
                faces.BorderElements.Add(p);
            }
            #endregion

            #region Bevel

            if (pieParams.Bevel && Math.Abs(pieParams.StartAngle - pieParams.StopAngle) > 0.03 && (pieParams.StartAngle != pieParams.StopAngle))
            {
                //Point startPoint = new Point();
                //Point endPoint = new Point();

                //startPoint.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StartAngle);
                //startPoint.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StartAngle);

                //endPoint.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StopAngle);
                //endPoint.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StopAngle);

                Point bevelCenter = new Point();
                Point bevelStart = new Point();
                Point bevelEnd = new Point();
                Double bevelLength = 4;
                Double bevelOuterRadius = Math.Abs(pieParams.OuterRadius - bevelLength);

                bevelCenter.X = center.X + bevelLength * Math.Cos(pieParams.MeanAngle);
                bevelCenter.Y = center.Y + bevelLength * Math.Sin(pieParams.MeanAngle);

                bevelStart.X = center.X + bevelOuterRadius * Math.Cos(pieParams.StartAngle + 0.03);
                bevelStart.Y = center.Y + bevelOuterRadius * Math.Sin(pieParams.StartAngle + 0.03);

                bevelEnd.X = center.X + bevelOuterRadius * Math.Cos(pieParams.StopAngle - 0.03);
                bevelEnd.Y = center.Y + bevelOuterRadius * Math.Sin(pieParams.StopAngle - 0.03);

                pathGeometry = new List<PathGeometryParams>();
                pathGeometry.Add(new LineSegmentParams(center));
                pathGeometry.Add(new LineSegmentParams(startPoint));
                pathGeometry.Add(new LineSegmentParams(bevelStart));
                pathGeometry.Add(new LineSegmentParams(bevelCenter));

                Path path = new Path() { Tag = new ElementData() { Element = pieParams.TagReference } };

                path.Data = GetPathGeometryFromList(FillRule.Nonzero, bevelCenter, pathGeometry, true);

                if (pieParams.StartAngle > Math.PI * 0.5 && pieParams.StartAngle <= Math.PI * 1.5)
                {
                    path.Fill = GetDarkerBevelBrush(pieParams.Background, pieParams.StartAngle * 180 / Math.PI + 135);
                }
                else
                {
                    path.Fill = GetLighterBevelBrush(pieParams.Background, -pieParams.StartAngle * 180 / Math.PI);
                }

                // Apply animation to the beveling path
                if (pieParams.AnimationEnabled)
                {
                    pieParams.Storyboard = CreateOpacityAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, path, 1, 1, 1);
                    path.Opacity = 0;
                }

                faces.Parts.Add(path);
                visual.Children.Add(path);

                pathGeometry = new List<PathGeometryParams>();
                pathGeometry.Add(new LineSegmentParams(center));
                pathGeometry.Add(new LineSegmentParams(endPoint));
                pathGeometry.Add(new LineSegmentParams(bevelEnd));
                pathGeometry.Add(new LineSegmentParams(bevelCenter));

                path = new Path() { Tag = new ElementData() { Element = pieParams.TagReference } };
                path.Data = GetPathGeometryFromList(FillRule.Nonzero, bevelCenter, pathGeometry, true);
                if (pieParams.StopAngle > Math.PI * 0.5 && pieParams.StopAngle <= Math.PI * 1.5)
                {
                    path.Fill = GetLighterBevelBrush(pieParams.Background, pieParams.StopAngle * 180 / Math.PI + 135);
                }
                else
                {
                    path.Fill = GetDarkerBevelBrush(pieParams.Background, -pieParams.StopAngle * 180 / Math.PI);
                }

                // Apply animation to the beveling path
                if (pieParams.AnimationEnabled)
                {
                    pieParams.Storyboard = CreateOpacityAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, path, 1, 1, 1);
                    path.Opacity = 0;
                }

                faces.Parts.Add(path);
                visual.Children.Add(path);

                #region "Outer Bevel"
                Shape outerBevel;

                if (enabledDataPoints.Count == 1 || noOfNonZeroDataPoint.Count() == 1)
                {
                    outerBevel = new Ellipse() { Height = pieParams.OuterRadius * 2, Width = pieParams.OuterRadius * 2, Tag = new ElementData() { Element = pieParams.TagReference } };
                    GeometryGroup gg = new GeometryGroup();
                    gg.Children.Add(new EllipseGeometry() { Center = new Point(pieParams.OuterRadius, pieParams.OuterRadius), RadiusX = pieParams.OuterRadius, RadiusY = pieParams.OuterRadius });
                    gg.Children.Add(new EllipseGeometry() { Center = new Point(pieParams.OuterRadius, pieParams.OuterRadius), RadiusX = bevelOuterRadius, RadiusY = bevelOuterRadius });
                    outerBevel.Clip = gg;
                }
                else
                {
                    pathGeometry = new List<PathGeometryParams>();
                    pathGeometry.Add(new LineSegmentParams(endPoint));
                    pathGeometry.Add(new ArcSegmentParams(new Size(pieParams.OuterRadius, pieParams.OuterRadius), 0, pieParams.IsLargerArc, SweepDirection.Counterclockwise, startPoint));
                    pathGeometry.Add(new LineSegmentParams(bevelStart));
                    pathGeometry.Add(new ArcSegmentParams(new Size(bevelOuterRadius, bevelOuterRadius), 0, pieParams.IsLargerArc, SweepDirection.Clockwise, bevelEnd));

                    outerBevel = new Path() { Tag = new ElementData() { Element = pieParams.TagReference } };
                    (outerBevel as Path).Data = GetPathGeometryFromList(FillRule.Nonzero, bevelEnd, pathGeometry, true);
                }

                if (pieParams.MeanAngle > 0 && pieParams.MeanAngle < Math.PI)
                {
                    outerBevel.Fill = GetCurvedBevelBrush(pieParams.Background, pieParams.MeanAngle * 180 / Math.PI + 90, Graphics.GenerateDoubleCollection(-0.745, -0.85), Graphics.GenerateDoubleCollection(0, 1));
                }
                else
                {
                    outerBevel.Fill = GetCurvedBevelBrush(pieParams.Background, pieParams.MeanAngle * 180 / Math.PI + 90, Graphics.GenerateDoubleCollection(0.745, -0.99), Graphics.GenerateDoubleCollection(0, 1));
                }

                // Apply animation to the beveling path
                if (pieParams.AnimationEnabled)
                {
                    pieParams.Storyboard = CreateOpacityAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, outerBevel, 1, 1, 1);
                    outerBevel.Opacity = 0;
                }


                #endregion
                faces.Parts.Add(outerBevel);
                visual.Children.Add(outerBevel);
            }
            else
            {
                faces.Parts.Add(null);
                faces.Parts.Add(null);
                faces.Parts.Add(null);
            }

            #endregion LabelLine

            return visual;
        }
Beispiel #2
0
        /// <summary>
        /// Return visual object for doughnut chart
        /// </summary>
        /// <param name="width">Width of the PlotArea</param>
        /// <param name="height">Height of the PlotArea</param>
        /// <param name="plotDetails">PlotDetails reference</param>
        /// <param name="seriesList">List of series list</param>
        /// <param name="chart">Chart reference</param>
        /// <param name="animationEnabled">Whether animation is enabled</param>
        /// <returns>Canvas</returns>
        internal static Canvas GetVisualObjectForDoughnutChart(Double widthOfPlotArea, Double height, PlotDetails plotDetails, List<DataSeries> seriesList, Chart chart, bool animationEnabled)
        {
            if (Double.IsNaN(widthOfPlotArea) || Double.IsNaN(height) || widthOfPlotArea <= 0 || height <= 0) return null;

            DataSeries currentDataSeries = null;

            Canvas visual = new Canvas();
            visual.Width = widthOfPlotArea;
            visual.Height = height;

            DataSeries series = seriesList[0];

            if (series.Enabled == false)
                return visual;

            // List<DataPoint> enabledDataPoints = (from datapoint in series.InternalDataPoints where datapoint.Enabled == true && datapoint.InternalYValue != 0 && !Double.IsNaN(datapoint.InternalYValue) select datapoint).ToList();
            List<DataPoint> enabledDataPoints = (from datapoint in series.InternalDataPoints where datapoint.Enabled == true && !Double.IsNaN(datapoint.InternalYValue) select datapoint).ToList();

            if ((from dp in enabledDataPoints select dp.InternalYValue).Sum() == 0)
                enabledDataPoints.Clear();

            Double absoluteSum = plotDetails.GetAbsoluteSumOfDataPoints(enabledDataPoints);

            absoluteSum = (absoluteSum == 0) ? 1 : absoluteSum;

            Double centerX = widthOfPlotArea / 2;
            Double centerY = height / 2;

            Double offsetX = 0;
            Double offsetY = 0;

            Size pieCanvas = new Size();
            Canvas labelCanvas = CreateAndPositionLabels(absoluteSum, enabledDataPoints, widthOfPlotArea, height, ((chart.View3D) ? 0.4 : 1), chart.View3D, ref pieCanvas);

            Double radius = Math.Min(pieCanvas.Width, pieCanvas.Height) / (chart.View3D ? 1 : 2);
            Double startAngle = series.InternalStartAngle;
            Double endAngle = 0;
            Double angle;
            Double meanAngle;
            Double absoluteYValue;
            Double radiusDiff = 0;

            var explodedDataPoints = (from datapoint in series.InternalDataPoints where datapoint.Exploded == true && datapoint.InternalYValue != 0 select datapoint);
            radiusDiff = (explodedDataPoints.Count() > 0) ? radius * 0.3 : 0;

            if (chart.View3D)
            {
                _elementPositionData = new List<ElementPositionData>();
            }

            if (labelCanvas != null)
            {
                labelCanvas.SetValue(Canvas.ZIndexProperty, 50001);
                labelCanvas.IsHitTestVisible = false;
            }

            if (series.Storyboard == null)
                series.Storyboard = new Storyboard();

            currentDataSeries = series;

            SectorChartShapeParams doughnutParams = null;

            Int32 labelStateCounter = 0;

            if (!chart.View3D)
            {
                foreach (DataPoint dataPoint in enabledDataPoints)
                {
                    if (dataPoint.LabelStyle == LabelStyles.Inside || !(Boolean)dataPoint.LabelEnabled)
                        labelStateCounter++;
                }
            }

            foreach (DataPoint dataPoint in enabledDataPoints)
            {
                if (Double.IsNaN(dataPoint.InternalYValue))// || dataPoint.InternalYValue == 0)
                    continue;

                absoluteYValue = Math.Abs(dataPoint.InternalYValue);

                angle = (absoluteYValue / absoluteSum) * Math.PI * 2;

                endAngle = startAngle + angle;
                meanAngle = (startAngle + endAngle) / 2;

                doughnutParams = new SectorChartShapeParams();
                dataPoint.VisualParams = doughnutParams;

                doughnutParams.AnimationEnabled = animationEnabled;
                doughnutParams.Storyboard = series.Storyboard;
                doughnutParams.ExplodeRatio = chart.View3D ? 0.2 : 0.1;
                doughnutParams.Center = new Point(centerX, centerY);
                doughnutParams.DataPoint = dataPoint;
                doughnutParams.InnerRadius = radius / 2;
                doughnutParams.OuterRadius = radius;

                if (chart.View3D)
                {
                    doughnutParams.StartAngle = doughnutParams.FixAngle((startAngle) % (Math.PI * 2));
                    doughnutParams.StopAngle = doughnutParams.FixAngle((endAngle) % (Math.PI * 2));
                }
                else
                {
                    doughnutParams.StartAngle = startAngle;
                    doughnutParams.StopAngle = endAngle;
                }

                doughnutParams.Lighting = (Boolean)dataPoint.LightingEnabled;
                doughnutParams.Bevel = series.Bevel;
                doughnutParams.IsLargerArc = (angle / (Math.PI)) > 1;
                doughnutParams.Background = dataPoint.Color;
                doughnutParams.Width = widthOfPlotArea;
                doughnutParams.Height = height;
                doughnutParams.TiltAngle = Math.Asin(0.4);
                doughnutParams.Depth = 20 / doughnutParams.YAxisScaling;

                doughnutParams.MeanAngle = meanAngle;
                doughnutParams.LabelLineEnabled = (Boolean)dataPoint.LabelLineEnabled;
                doughnutParams.LabelLineColor = dataPoint.LabelLineColor;
                doughnutParams.LabelLineThickness = (Double)dataPoint.LabelLineThickness;
                doughnutParams.LabelLineStyle = ExtendedGraphics.GetDashArray((LineStyles)dataPoint.LabelLineStyle);

                offsetX = radius * doughnutParams.ExplodeRatio * Math.Cos(meanAngle);
                offsetY = radius * doughnutParams.ExplodeRatio * Math.Sin(meanAngle);
                doughnutParams.OffsetX = offsetX;
                doughnutParams.OffsetY = offsetY * (chart.View3D ? doughnutParams.YAxisScaling : 1);

                if (dataPoint.LabelVisual != null)
                {
                    if (dataPoint.LabelVisual.Visibility == Visibility.Collapsed)
                        doughnutParams.LabelLineEnabled = false;

                    Double left = (Double)dataPoint.LabelVisual.GetValue(Canvas.LeftProperty);

                    if (left < widthOfPlotArea / 2)
                    {
                        doughnutParams.LabelLineTargetToRight = true;
                        // pieParams.LabelPoint = new Point((Double)dataPoint.LabelVisual.GetValue(Canvas.LeftProperty) + dataPoint.LabelVisual.DesiredSize.Width, (Double)dataPoint.LabelVisual.GetValue(Canvas.TopProperty) + dataPoint.LabelVisual.DesiredSize.Height / 2);
                        doughnutParams.LabelPoint = new Point(left + dataPoint.LabelVisual.Width + LabelPlacementHelper.LABEL_LINE_GAP, (Double)dataPoint.LabelVisual.GetValue(Canvas.TopProperty) + dataPoint.LabelVisual.Height / 2);
                    }
                    else
                    {
                        doughnutParams.LabelLineTargetToRight = false;
                        doughnutParams.LabelPoint = new Point(left - LabelPlacementHelper.LABEL_LINE_GAP, (Double)dataPoint.LabelVisual.GetValue(Canvas.TopProperty) + dataPoint.LabelVisual.Height / 2);
                    }

                    //if ((Double)dataPoint.LabelVisual.GetValue(Canvas.LeftProperty) < width / 2)
                    //{
                    //    doughnutParams.LabelPoint = new Point((Double)dataPoint.LabelVisual.GetValue(Canvas.LeftProperty) + dataPoint.LabelVisual.Width + LABEL_LINE_GAP, (Double)dataPoint.LabelVisual.GetValue(Canvas.TopProperty) + dataPoint.LabelVisual.Height / 2);
                    //}
                    //else
                    //{
                    //    doughnutParams.LabelPoint = new Point((Double)dataPoint.LabelVisual.GetValue(Canvas.LeftProperty) - LABEL_LINE_GAP, (Double)dataPoint.LabelVisual.GetValue(Canvas.TopProperty) + dataPoint.LabelVisual.Height / 2);
                    //}

                    // apply animation to the labels
                    if (animationEnabled)
                    {
                        series.Storyboard = CreateOpacityAnimation(currentDataSeries, doughnutParams.DataPoint, series.Storyboard, dataPoint.LabelVisual, 2, 1, 0.5);
                        dataPoint.LabelVisual.Opacity = 0;
                    }

                   
                }

                if (dataPoint.LabelStyle == LabelStyles.Inside && dataPoint.InternalYValue == 0)
                    doughnutParams.LabelLineEnabled = false;

                Faces faces = new Faces();
                faces.Parts = new List<DependencyObject>();

                doughnutParams.TagReference = dataPoint;

                if (chart.View3D)
                {
                    PieDoughnut3DPoints unExplodedPoints = new PieDoughnut3DPoints();
                    PieDoughnut3DPoints explodedPoints = new PieDoughnut3DPoints();
                    List<Shape> doughnutFaces = GetDoughnut3D(currentDataSeries, ref faces, doughnutParams, ref unExplodedPoints, ref explodedPoints, ref dataPoint.LabelLine, enabledDataPoints);

                    foreach (Shape path in doughnutFaces)
                    {   
                        if (path != null)
                        {   
                            visual.Children.Add(path);
                            faces.VisualComponents.Add(path);
                            faces.BorderElements.Add(path);

                            path.RenderTransform = new TranslateTransform();

                            // apply animation to the 3D sections
                            if (animationEnabled)
                            {
                                series.Storyboard = CreateOpacityAnimation(currentDataSeries, doughnutParams.DataPoint, series.Storyboard, path, 1.0 / (series.InternalDataPoints.Count) * (series.InternalDataPoints.IndexOf(dataPoint)), dataPoint.InternalOpacity, 0.5);
                                path.Opacity = 0;
                            }
                        }
                    }
                    if (dataPoint.LabelLine != null && doughnutParams.LabelLineEnabled)
                    {
                        dataPoint.LabelLine.RenderTransform = new TranslateTransform();
                        visual.Children.Add(dataPoint.LabelLine);

                        if (dataPoint.InternalYValue == 0)
                        {
                            Double yOffset = doughnutParams.YAxisScaling;
                            Line zeroLine = new Line();
                            zeroLine.X1 = doughnutParams.Center.X + doughnutParams.InnerRadius * Math.Cos(doughnutParams.MeanAngle);
                            zeroLine.Y1 = doughnutParams.Center.Y + doughnutParams.InnerRadius * Math.Sin(doughnutParams.MeanAngle);
                            zeroLine.Y1 -= offsetY;
                            zeroLine.Y1 += doughnutParams.Depth / 2 * doughnutParams.ZAxisScaling;
                            zeroLine.X2 = unExplodedPoints.LabelLineStartPoint.X;
                            zeroLine.Y2 = unExplodedPoints.LabelLineStartPoint.Y;
                            zeroLine.Stroke = doughnutParams.LabelLineColor;
                            zeroLine.StrokeThickness = 0.25;
                            zeroLine.IsHitTestVisible = false;
                            visual.Children.Add(zeroLine);

                            if (animationEnabled)
                            {
                                series.Storyboard = CreateOpacityAnimation(currentDataSeries, doughnutParams.DataPoint, series.Storyboard, zeroLine, 2, zeroLine.Opacity, 0.5);
                                zeroLine.Opacity = 0;
                            }
                        }

                        faces.VisualComponents.Add(dataPoint.LabelLine);
                    }

                    faces.Visual = visual;

                    UpdateExplodedPosition(doughnutParams, dataPoint, offsetX, unExplodedPoints, explodedPoints, widthOfPlotArea);

                    ///------------------------
                    dataPoint.ExplodeAnimation = new Storyboard();
                    dataPoint.ExplodeAnimation = CreateExplodingOut3DAnimation(currentDataSeries, dataPoint, dataPoint.ExplodeAnimation, doughnutFaces, dataPoint.LabelVisual as Canvas, dataPoint.LabelLine, unExplodedPoints, explodedPoints, doughnutParams.OffsetX, doughnutParams.OffsetY);
                    dataPoint.UnExplodeAnimation = new Storyboard();
                    dataPoint.UnExplodeAnimation = CreateExplodingIn3DAnimation(currentDataSeries, dataPoint, dataPoint.UnExplodeAnimation, doughnutFaces, dataPoint.LabelVisual as Canvas, dataPoint.LabelLine, unExplodedPoints, explodedPoints, doughnutParams.OffsetX, doughnutParams.OffsetY);
                }
                else
                {
                    PieDoughnut2DPoints unExplodedPoints = new PieDoughnut2DPoints();
                    PieDoughnut2DPoints explodedPoints = new PieDoughnut2DPoints();

                    if (labelStateCounter == enabledDataPoints.Count)
                    {
                        doughnutParams.OuterRadius -= doughnutParams.OuterRadius * doughnutParams.ExplodeRatio;
                        doughnutParams.InnerRadius = doughnutParams.OuterRadius / 2;
                    }

                    Canvas pieVisual = GetDoughnut2D(currentDataSeries, ref faces, doughnutParams, ref unExplodedPoints, ref explodedPoints, ref dataPoint.LabelLine, enabledDataPoints);

                    UpdateExplodedPosition(doughnutParams, dataPoint, offsetX, unExplodedPoints, explodedPoints, widthOfPlotArea);

                    TranslateTransform translateTransform = new TranslateTransform();
                    pieVisual.RenderTransform = translateTransform;
                    dataPoint.ExplodeAnimation = new Storyboard();
                    dataPoint.ExplodeAnimation = CreateExplodingOut2DAnimation(currentDataSeries, dataPoint, dataPoint.ExplodeAnimation, pieVisual, dataPoint.LabelVisual as Canvas, dataPoint.LabelLine, translateTransform, unExplodedPoints, explodedPoints, offsetX, offsetY);
                    dataPoint.UnExplodeAnimation = new Storyboard();
                    dataPoint.UnExplodeAnimation = CreateExplodingIn2DAnimation(currentDataSeries, dataPoint, dataPoint.UnExplodeAnimation, pieVisual, dataPoint.LabelVisual as Canvas, dataPoint.LabelLine, translateTransform, unExplodedPoints, explodedPoints, offsetX, offsetY);

                    pieVisual.SetValue(Canvas.TopProperty, height / 2 - pieVisual.Height / 2);
                    pieVisual.SetValue(Canvas.LeftProperty, widthOfPlotArea / 2 - pieVisual.Width / 2);
                    visual.Children.Add(pieVisual);
                    faces.VisualComponents.Add(pieVisual);
                    faces.Visual = pieVisual;
                }

                dataPoint.Faces = faces;

                startAngle = endAngle;

                if (!chart.AnimationEnabled || chart.IsInDesignMode || !chart.ChartArea._isFirstTimeRender)
                {
                    if (dataPoint.Faces != null)
                    {
                        foreach (Shape shape in dataPoint.Faces.BorderElements)
                        {
                            InteractivityHelper.ApplyBorderEffect(shape, (BorderStyles)dataPoint.BorderStyle, dataPoint.InternalBorderThickness.Left, dataPoint.BorderColor);
                        }
                    }
                }
            }

            if (chart.View3D)
            {
                Int32 zindex1, zindex2;
                _elementPositionData.Sort(ElementPositionData.CompareAngle);
                zindex1 = 1000;
                zindex2 = -1000;
                for (Int32 i = 0; i < _elementPositionData.Count; i++)
                {
                    SetZIndex(_elementPositionData[i].Element, ref zindex1, ref zindex2, _elementPositionData[i].StartAngle);
                }
            }

            if (labelCanvas != null)
                visual.Children.Add(labelCanvas);

            RectangleGeometry clipRectangle = new RectangleGeometry();
            clipRectangle.Rect = new Rect(0, 0, widthOfPlotArea, height);
            visual.Clip = clipRectangle;

            return visual;
        }
Beispiel #3
0
        /// <summary>
        /// Create exploding in animation for 2D Pie/Doughnut
        /// </summary>
        /// <param name="dataPoint">DataPoint</param>
        /// <param name="storyboard">Stroyboard used for animation</param>
        /// <param name="pathElements">Path elements reference</param>
        /// <param name="label">Label reference</param>
        /// <param name="labelLine">Label line reference</param>
        /// <param name="unExplodedPoints">Unexploded points</param>
        /// <param name="explodedPoints">Exploded points</param>
        /// <param name="xOffset">X offset</param>
        /// <param name="yOffset">Y offset</param>
        /// <returns>Storyboard</returns>
        private static Storyboard CreateExplodingIn2DAnimation(DataSeries currentDataSeries, DataPoint dataPoint, Storyboard storyboard, Panel visual, Panel label, Path labelLine, TranslateTransform translateTransform, PieDoughnut2DPoints unExplodedPoints, PieDoughnut2DPoints explodedPoints, Double xOffset, Double yOffset)
        {

            #region Animating Silce
            DoubleCollection values = Graphics.GenerateDoubleCollection(xOffset, 0);
            DoubleCollection frames = Graphics.GenerateDoubleCollection(0, 0.4);
            List<KeySpline> splines = AnimationHelper.GenerateKeySplineList
                (
                    new Point(0, 0), new Point(1, 1),
                    new Point(0, 0), new Point(0, 1)
                );

            DoubleAnimationUsingKeyFrames sliceXAnimation = CreateDoubleAnimation(currentDataSeries, dataPoint, translateTransform, "(TranslateTransform.X)", 0, frames, values, splines);

            values = Graphics.GenerateDoubleCollection(yOffset, 0);
            frames = Graphics.GenerateDoubleCollection(0, 0.4);
            splines = AnimationHelper.GenerateKeySplineList
                (
                    new Point(0, 0), new Point(1, 1),
                    new Point(0, 0), new Point(0, 1)
                );

            DoubleAnimationUsingKeyFrames sliceYAnimation = CreateDoubleAnimation(currentDataSeries, dataPoint, translateTransform, "(TranslateTransform.Y)", 0, frames, values, splines);

            storyboard.Children.Add(sliceXAnimation);
            storyboard.Children.Add(sliceYAnimation);
            #endregion Animating Silce

            #region Animating Label
            if (dataPoint.LabelStyle == LabelStyles.Inside)
            {
                if (label != null)
                {

                    translateTransform = label.RenderTransform as TranslateTransform;
                    values = Graphics.GenerateDoubleCollection(xOffset, 0);
                    frames = Graphics.GenerateDoubleCollection(0, 0.4);
                    splines = AnimationHelper.GenerateKeySplineList
                    (
                        new Point(0, 0), new Point(1, 1),
                        new Point(0, 0), new Point(0, 1)
                    );

                    DoubleAnimationUsingKeyFrames labelXAnimation = CreateDoubleAnimation(currentDataSeries, dataPoint, translateTransform, "(TranslateTransform.X)", 0, frames, values, splines);

                    values = Graphics.GenerateDoubleCollection(yOffset, 0);
                    frames = Graphics.GenerateDoubleCollection(0, 0.4);
                    splines = AnimationHelper.GenerateKeySplineList
                    (
                        new Point(0, 0), new Point(1, 1),
                        new Point(0, 0), new Point(0, 1)
                    );

                    DoubleAnimationUsingKeyFrames labelYAnimation = CreateDoubleAnimation(currentDataSeries, dataPoint, translateTransform, "(TranslateTransform.Y)", 0, frames, values, splines);

                    storyboard.Children.Add(labelXAnimation);
                    storyboard.Children.Add(labelYAnimation);
                }
            }
            else
            {
                values = Graphics.GenerateDoubleCollection(explodedPoints.LabelPosition.X, unExplodedPoints.LabelPosition.X);
                frames = Graphics.GenerateDoubleCollection(0, 0.4);
                splines = AnimationHelper.GenerateKeySplineList
                    (
                        new Point(0, 0), new Point(1, 1),
                        new Point(0, 0), new Point(0, 1)
                    );

                DoubleAnimationUsingKeyFrames labelXAnimation = CreateDoubleAnimation(currentDataSeries, dataPoint, label, "(Canvas.Left)", 0, frames, values, splines);
                storyboard.Children.Add(labelXAnimation);
            }

            #endregion Animating Label

            #region Animating Label Line

            if (labelLine != null)
            {
                PathFigure figure = (labelLine.Data as PathGeometry).Figures[0];
                PathSegmentCollection segments = figure.Segments;
                storyboard = CreateLabelLineInteractivityAnimation(currentDataSeries, dataPoint, storyboard, segments[0], explodedPoints.LabelLineMidPoint, unExplodedPoints.LabelLineMidPoint);
                storyboard = CreateLabelLineInteractivityAnimation(currentDataSeries, dataPoint, storyboard, segments[1], explodedPoints.LabelLineEndPoint, unExplodedPoints.LabelLineEndPoint);
            }

            #endregion Animating Label Line
            return storyboard;
        }
Beispiel #4
0
        /// <summary>
        /// Create3DPie
        /// </summary>
        /// <param name="width">Visual width</param>
        /// <param name="height">Visual height</param>
        /// <param name="series">DataSeries</param>
        /// <param name="enabledDataPoints"> Enabled InternalDataPoints in the DataSeries</param>
        /// <param name="dataPoint">DataPoint reference</param>
        /// <param name="visual">visual canvas reference</param>
        /// <param name="faces">Visual faces</param>
        /// <param name="pieParams">Pie parameters</param>
        /// <param name="offsetX">X offset</param>
        /// <param name="offsetX">Y offset</param>
        /// <param name="zindex">Z index of the pie</param>
        /// <param name="isAnimationEnabled">Whether animation is enabled</param>
        /// <param name="labelStyleCounter">labelStyle count</param>
        private static void Create2DPie(DataSeries currentDataSeries, Double widthOfPlotArea, Double height, DataSeries series, List<DataPoint> enabledDataPoints, DataPoint dataPoint, ref Canvas visual, ref Faces faces, ref SectorChartShapeParams pieParams, ref Double offsetX, ref Double offsetY, ref Int32 zindex, Boolean isAnimationEnabled, Int32 labelStateCount)
        {
            #region 2D Pie

            PieDoughnut2DPoints unExplodedPoints = new PieDoughnut2DPoints();
            PieDoughnut2DPoints explodedPoints = new PieDoughnut2DPoints();

            pieParams.TagReference = dataPoint;

            if (labelStateCount == enabledDataPoints.Count)
                pieParams.OuterRadius -= pieParams.OuterRadius * pieParams.ExplodeRatio;

            Canvas pieVisual = GetPie2D(currentDataSeries, ref faces, pieParams, ref unExplodedPoints, ref explodedPoints, ref dataPoint.LabelLine, enabledDataPoints);

            UpdateExplodedPosition(pieParams, dataPoint, offsetX, unExplodedPoints, explodedPoints, widthOfPlotArea);

            TranslateTransform translateTransform = new TranslateTransform();
            pieVisual.RenderTransform = translateTransform;
            dataPoint.ExplodeAnimation = new Storyboard();
            dataPoint.ExplodeAnimation = CreateExplodingOut2DAnimation(currentDataSeries, dataPoint, dataPoint.ExplodeAnimation, pieVisual, dataPoint.LabelVisual as Canvas, dataPoint.LabelLine, translateTransform, unExplodedPoints, explodedPoints, offsetX, offsetY);
            dataPoint.UnExplodeAnimation = new Storyboard();
            dataPoint.UnExplodeAnimation = CreateExplodingIn2DAnimation(currentDataSeries, dataPoint, dataPoint.UnExplodeAnimation, pieVisual, dataPoint.LabelVisual as Canvas, dataPoint.LabelLine, translateTransform, unExplodedPoints, explodedPoints, offsetX, offsetY);

            pieVisual.SetValue(Canvas.TopProperty, height / 2 - pieVisual.Height / 2);
            pieVisual.SetValue(Canvas.LeftProperty, widthOfPlotArea / 2 - pieVisual.Width / 2);
            visual.Children.Add(pieVisual);
            faces.VisualComponents.Add(pieVisual);
            faces.Visual = pieVisual;

            #endregion
        }
Beispiel #5
0
        /// <summary>
        /// Create3DPie
        /// </summary>
        /// <param name="width">Visual width</param>
        /// <param name="height">Visual height</param>
        /// <param name="series">DataSeries</param>
        /// <param name="enabledDataPoints"> Enabled InternalDataPoints in the DataSeries</param>
        /// <param name="dataPoint">DataPoint reference</param>
        /// <param name="visual">visual canvas reference</param>
        /// <param name="faces">Visual faces</param>
        /// <param name="pieParams">Pie parameters</param>
        /// <param name="offsetX">X offset</param>
        /// <param name="offsetX">Y offset</param>
        /// <param name="zindex">Z index of the pie</param>
        /// <param name="isAnimationEnabled">Whether animation is enabled</param>
        /// <param name="labelStyleCounter">labelStyle count</param>
        private static void Create2DPie(DataSeries currentDataSeries, Double widthOfPlotArea, Double height, DataSeries series, List<DataPoint> enabledDataPoints, DataPoint dataPoint, ref Canvas visual, ref Faces faces, ref SectorChartShapeParams pieParams, ref Double offsetX, ref Double offsetY, ref Int32 zindex, Boolean isAnimationEnabled, Int32 labelStateCount)
        {
            #region 2D Pie

            PieDoughnut2DPoints unExplodedPoints = new PieDoughnut2DPoints();
            PieDoughnut2DPoints explodedPoints = new PieDoughnut2DPoints();

            pieParams.TagReference = dataPoint;

            if (labelStateCount == enabledDataPoints.Count)
                pieParams.OuterRadius -= pieParams.OuterRadius * pieParams.ExplodeRatio;

            Canvas pieVisual = GetPie2D(currentDataSeries, ref faces, pieParams, ref unExplodedPoints, ref explodedPoints, ref dataPoint.LabelLine, enabledDataPoints);

            UpdateExplodedPosition(pieParams, dataPoint, offsetX, unExplodedPoints, explodedPoints, widthOfPlotArea);

            pieParams.ExplodedPoints = explodedPoints;
            pieParams.UnExplodedPoints = unExplodedPoints;

            TranslateTransform translateTransform = new TranslateTransform();
            pieVisual.RenderTransform = translateTransform;

            if ((Boolean)(currentDataSeries.Chart as Chart).AnimatedUpdate)
            {
                dataPoint.ExplodeAnimation = new Storyboard();
                dataPoint.ExplodeAnimation = CreateExplodingOut2DAnimation(currentDataSeries, dataPoint, widthOfPlotArea, dataPoint.ExplodeAnimation, pieVisual, dataPoint.LabelVisual as Canvas, dataPoint.LabelLine, translateTransform, unExplodedPoints, explodedPoints, offsetX, offsetY);
                dataPoint.UnExplodeAnimation = new Storyboard();
                dataPoint.UnExplodeAnimation = CreateExplodingIn2DAnimation(currentDataSeries, dataPoint, widthOfPlotArea, dataPoint.UnExplodeAnimation, pieVisual, dataPoint.LabelVisual as Canvas, dataPoint.LabelLine, translateTransform, unExplodedPoints, explodedPoints, offsetX, offsetY);
            }
            else
            {
                if (!(currentDataSeries.Chart as Chart).InternalAnimationEnabled)
                {
                    if ((Boolean)dataPoint.Exploded)
                    {
                        translateTransform.X = offsetX;
                        translateTransform.Y = offsetY;

                        if (dataPoint.LabelVisual != null)
                        {
                            if (dataPoint.LabelStyle == LabelStyles.Inside)
                            {
                                translateTransform = new TranslateTransform();
                                (dataPoint.LabelVisual as Canvas).RenderTransform = translateTransform;

                                translateTransform.X = offsetX;
                                translateTransform.Y = offsetY;
                            }
                            else
                            {
                                (dataPoint.LabelVisual as Canvas).SetValue(Canvas.LeftProperty, explodedPoints.LabelPosition.X);
                            }
                        }

                        if (dataPoint.LabelLine != null)
                        {
                            PathFigure figure = (dataPoint.LabelLine.Data as PathGeometry).Figures[0];
                            PathSegmentCollection segments = figure.Segments;
                            (segments[0] as LineSegment).Point = explodedPoints.LabelLineMidPoint;
                            (segments[1] as LineSegment).Point = explodedPoints.LabelLineEndPoint;
                        }

                        dataPoint._interactiveExplodeState = true;
                    }
                }
            }

            pieVisual.SetValue(Canvas.TopProperty, height / 2 - pieVisual.Height / 2);
            pieVisual.SetValue(Canvas.LeftProperty, widthOfPlotArea / 2 - pieVisual.Width / 2);
            visual.Children.Add(pieVisual);
            faces.VisualComponents.Add(pieVisual);
            faces.Visual = pieVisual;

            #endregion
        }