Пример #1
0
 internal override void UpdateEmptyPointSegments(List <double> xValues, bool isSidebySideSeries)
 {
     if (EmptyPointIndexes != null)
     {
         foreach (var item in EmptyPointIndexes[0])
         {
             DoughnutSegment segment = Segments[item] as DoughnutSegment;
             bool            explode = segment.IsExploded;
             Segments[item].IsEmptySegmentInterior            = true;
             (Segments[item] as DoughnutSegment).AngleOfSlice = segment.AngleOfSlice;
             (Segments[item] as DoughnutSegment).IsExploded   = explode;
             if (Adornments.Count > 0)
             {
                 Adornments[item].IsEmptySegmentInterior = true;
             }
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Creates the doughnut segments.
        /// </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;
                }
            }

            double arcEndAngle = DegreeToRadianConverter(EndAngle), arcStartAngle = DegreeToRadianConverter(StartAngle);

            if (arcStartAngle == arcEndAngle)
            {
                Segments.Clear();
            }
            ARCLENGTH = arcEndAngle - arcStartAngle;
            if (Math.Abs(Math.Round(ARCLENGTH, 2)) > TotalArcLength)
            {
                ARCLENGTH = ARCLENGTH % TotalArcLength;
            }
            ClearUnUsedAdornments(this.DataCount);
            ClearUnUsedSegments(this.DataCount);
            int  explodedIndex = ExplodeIndex;
            bool explodedAll   = ExplodeAll;

            if (xValues != null)
            {
                var grandTotal = (from val in toggledYValues
                                  select(val) > 0 ? val : Math.Abs(double.IsNaN(val) ? 0 : val)).Sum();

                var  isMultipleDoughnut  = !double.IsNaN(MaximumValue) && IsStackedDoughnut && GetDoughnutSeriesCount() == 1;
                bool isEndValueExceed    = false;
                var  visibleSegmentCount = 0;

                for (int i = 0; i < xValues.Count; i++)
                {
                    isEndValueExceed = false;
                    if (isMultipleDoughnut)
                    {
                        isEndValueExceed = (toggledYValues[i] >= MaximumValue);
                        arcEndAngle      = grandTotal == 0 ? 0 : (Math.Abs(double.IsNaN(toggledYValues[i]) ? 0 : isEndValueExceed ? MaximumValue : toggledYValues[i]) * (ARCLENGTH / MaximumValue));
                    }
                    else
                    {
                        arcEndAngle = grandTotal == 0 ? 0 : (Math.Abs(double.IsNaN(toggledYValues[i]) ? 0 : toggledYValues[i]) * (ARCLENGTH / grandTotal));
                    }

                    if (i < Segments.Count)
                    {
                        var doughnutSegment = Segments[i] as DoughnutSegment;

                        doughnutSegment.SetData(arcStartAngle, arcStartAngle + arcEndAngle, this);
                        doughnutSegment.XData                = xValues[i];
                        doughnutSegment.YData                = !double.IsNaN(GroupTo) ? Math.Abs(toggledYValues[i]) : Math.Abs(YValues[i]);
                        doughnutSegment.AngleOfSlice         = (2 * arcStartAngle + arcEndAngle) / 2;
                        doughnutSegment.IsExploded           = explodedAll || (explodedIndex == i);
                        doughnutSegment.Item                 = actualData[i];
                        doughnutSegment.IsEndValueExceed     = isEndValueExceed;
                        doughnutSegment.DoughnutSegmentIndex = visibleSegmentCount;
                        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;
                        }

                        doughnutSegment.UpdateTrackInterior(i);
                    }
                    else
                    {
                        DoughnutSegment segment = new DoughnutSegment(arcStartAngle, arcStartAngle + arcEndAngle,
                                                                      this)
                        {
                            XData                = xValues[i],
                            YData                = !double.IsNaN(GroupTo) ? Math.Abs(toggledYValues[i]) : Math.Abs(YValues[i]),
                            AngleOfSlice         = (2 * arcStartAngle + arcEndAngle) / 2,
                            IsExploded           = explodedAll || (explodedIndex == i),
                            Item                 = actualData[i],
                            IsEndValueExceed     = isEndValueExceed,
                            DoughnutSegmentIndex = visibleSegmentCount
                        };

                        segment.SetData(arcStartAngle, arcStartAngle + arcEndAngle,
                                        this);
                        if (ToggledLegendIndex.Contains(i))
                        {
                            segment.IsSegmentVisible = false;
                        }
                        else
                        {
                            segment.IsSegmentVisible = true;
                        }
                        Segments.Add(segment);

                        segment.UpdateTrackInterior(i);
                    }

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

                    if (!double.IsNaN(toggledYValues[i]))
                    {
                        visibleSegmentCount++;
                    }

                    if (!IsStackedDoughnut)
                    {
                        arcStartAngle += arcEndAngle;
                    }
                }

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

                UpdateSegmentGapAngle();
            }
        }