Exemplo n.º 1
0
 internal override void UpdateEmptyPointSegments(List <double> xValues, bool isSidebySideSeries)
 {
     if (EmptyPointIndexes != null)
     {
         foreach (var item in EmptyPointIndexes[0])
         {
             PieSegment segment = Segments[item] as PieSegment;
             bool       explode = segment.IsExploded;
             Segments[item].IsEmptySegmentInterior       = true;
             (Segments[item] as PieSegment).AngleOfSlice = segment.AngleOfSlice;
             (Segments[item] as PieSegment).IsExploded   = explode;
             if (Adornments.Count > 0)
             {
                 Adornments[item].IsEmptySegmentInterior = true;
             }
         }
     }
 }
Exemplo n.º 2
0
        private void AddPieAdornments(double x, double y, double startAngle, double endAngle, int i, int index, PieSegment pieSegment)
        {
            double angle = (startAngle + endAngle) / 2;

            if (Area == null || Area.RootPanelDesiredSize == null || Area.RootPanelDesiredSize.Value == null)
            {
                return;
            }

            var actualheight = Area.RootPanelDesiredSize.Value.Height;
            var actualwidth  = Area.RootPanelDesiredSize.Value.Width;

            var pieSeries      = (from series in Area.VisibleSeries where series is PieSeries select series).ToList();
            var pieSeriesCount = pieSeries.Count();

            double pieIndex     = pieSeries.IndexOf(this);
            double actualRadius = (Math.Min(actualwidth, actualheight)) / 2;
            double equalParts   = actualRadius / (pieSeriesCount);
            double radius       = (equalParts * (pieIndex + 1)) - (equalParts * (1 - InternalPieCoefficient));

            if (index < Adornments.Count)
            {
                (Adornments[index] as ChartPieAdornment).SetData(x, y, angle, radius);
            }
            else
            {
                Adornments.Add(this.CreateAdornment(this, x, y, angle, radius));
            }

            Adornments[index].Item = !double.IsNaN(GroupTo) ? Segments[index].Item : ActualData[index];
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the segments of PieSeries.
        /// </summary>
        public override void CreateSegments()
        {
            IList <double> toggledYValues = null;
            List <double>  xValues        = null;
            var            actualData     = ActualData;

            if (double.IsNaN(GroupTo))
            {
                if (ToggledLegendIndex.Count > 0)
                {
                    toggledYValues = GetYValues();
                }
                else
                {
                    toggledYValues = YValues;
                }

                xValues = GetXValues();
            }
            else
            {
                if (Adornments != null)
                {
                    Adornments.Clear();
                }
                if (Segments != null)
                {
                    Segments.Clear();
                }

                var sumOfYValues = (from val in YValues
                                    select(val) > 0 ? val : Math.Abs(double.IsNaN(val) ? 0 : val)).Sum();
                double xIndexValues = 0d;
                xValues = (from val in YValues where GetGroupModeValue(val, sumOfYValues) > GroupTo select(xIndexValues++)).ToList();
                if (YValues.Count > xValues.Count)
                {
                    xValues.Add(xIndexValues);
                }

                var groupToValues = GetGroupToYValues();
                actualData = groupToValues.Item2;

                if (ToggledLegendIndex.Count > 0)
                {
                    toggledYValues = GetToggleYValues(groupToValues.Item1);
                }
                else
                {
                    toggledYValues = groupToValues.Item1;
                }
            }

            ClearUnUsedAdornments(this.DataCount);
            ClearUnUsedSegments(this.DataCount);
            int  explodedIndex = ExplodeIndex;
            bool explodedAll   = ExplodeAll;

            arcStartAngle = DegreeToRadianConverter(StartAngle);
            arcEndAngle   = DegreeToRadianConverter(EndAngle);
            if (arcStartAngle == arcEndAngle)
            {
                Segments.Clear();
            }
            ARCLENGTH = arcEndAngle - arcStartAngle;
            if (Math.Abs(Math.Round(ARCLENGTH, 2)) > TotalArcLength)
            {
                ARCLENGTH = ARCLENGTH % TotalArcLength;
            }
            if (xValues != null)
            {
                grandTotal = (from val in toggledYValues
                              select(val) > 0 ? val : Math.Abs(double.IsNaN(val) ? 0 : val)).Sum();
                for (int i = 0; i < xValues.Count; i++)
                {
                    arcEndAngle = grandTotal == 0 ? 0 : (Math.Abs(double.IsNaN(toggledYValues[i]) ? 0 : toggledYValues[i]) * (ARCLENGTH / grandTotal));

                    if (i < Segments.Count)
                    {
                        (Segments[i] as PieSegment).SetData(
                            arcStartAngle,
                            arcStartAngle + arcEndAngle,
                            this,
                            actualData[i]);
                        (Segments[i] as PieSegment).XData        = xValues[i];
                        (Segments[i] as PieSegment).YData        = !double.IsNaN(GroupTo) ? Math.Abs(toggledYValues[i]) : Math.Abs(YValues[i]);
                        (Segments[i] as PieSegment).AngleOfSlice = (2 * arcStartAngle + arcEndAngle) / 2;
                        (Segments[i] as PieSegment).IsExploded   = explodedAll || (explodedIndex == i);
                        (Segments[i] as PieSegment).Item         = actualData[i];
                        if (SegmentColorPath != null && !Segments[i].IsEmptySegmentInterior && ColorValues.Count > 0 && !Segments[i].IsSelectedSegment)
                        {
                            Segments[i].Interior = (Interior != null) ? Interior : ColorValues[i];
                        }
                        if (ToggledLegendIndex.Contains(i))
                        {
                            Segments[i].IsSegmentVisible = false;
                        }
                        else
                        {
                            Segments[i].IsSegmentVisible = true;
                        }
                    }
                    else
                    {
                        var segment = new PieSegment(arcStartAngle, arcStartAngle + arcEndAngle, this, actualData[i]);

                        segment.SetData(arcStartAngle, arcStartAngle + arcEndAngle, this, actualData[i]);

                        segment.XData        = xValues[i];
                        segment.YData        = !double.IsNaN(GroupTo) ? Math.Abs(toggledYValues[i]) : Math.Abs(YValues[i]);
                        segment.AngleOfSlice = (2 * arcStartAngle + arcEndAngle) / 2;
                        segment.IsExploded   = explodedAll || explodedIndex == i;
                        segment.Item         = actualData[i];
                        if (ToggledLegendIndex.Contains(i))
                        {
                            segment.IsSegmentVisible = false;
                        }
                        else
                        {
                            segment.IsSegmentVisible = true;
                        }
                        Segments.Add(segment);
                    }

                    if (AdornmentsInfo != null)
                    {
                        AddPieAdornments(xValues[i], toggledYValues[i], arcStartAngle, arcStartAngle + arcEndAngle, Segments.Count - 1, i, Segments[i] as PieSegment);
                    }
                    arcStartAngle += arcEndAngle;
                }

                if (ShowEmptyPoints)
                {
                    UpdateEmptyPointSegments(xValues, false);
                }
            }
        }