Esempio n. 1
0
        /// <summary>
        /// To calculate the segments if the pyramid mode is surface
        /// </summary>
        private void CalculateSurfaceSegments(double sumValues, int count, double gapHeight, List <double> xValues)
        {
            var toggledYValues = YValues.ToList();

            if (ToggledLegendIndex.Count > 0)
            {
                toggledYValues = GetYValues();
            }
            currY = 0;
            double[] y      = new double[count];
            double[] height = new double[count];
            double   preSum = GetSurfaceHeight(0, sumValues);

            for (int i = 0; i < count; i++)
            {
                y[i]      = currY;
                height[i] = GetSurfaceHeight(currY, Math.Abs(double.IsNaN(toggledYValues[i]) ? 0 : toggledYValues[i]));
                currY    += height[i] + gapHeight * preSum;
            }

            double coef = 1 / (currY - gapHeight * preSum);

            for (int i = 0; i < count; i++)
            {
                double currHeight = 0;
                if (!double.IsNaN(YValues[i]))
                {
                    currHeight = coef * y[i];
                    PyramidSegment pyramidSegment = new PyramidSegment(currHeight, coef * height[i], this.ExplodeOffset, this, i == this.ExplodeIndex || this.ExplodeAll ? true : false);
                    pyramidSegment.Item  = ActualData[i];
                    pyramidSegment.XData = xValues[i];
                    pyramidSegment.YData = Math.Abs(YValues[i]);
                    if (ToggledLegendIndex.Contains(i))
                    {
                        pyramidSegment.IsSegmentVisible = false;
                    }
                    else
                    {
                        pyramidSegment.IsSegmentVisible = true;
                    }
                    this.Segments.Add(pyramidSegment);

                    if (AdornmentsInfo != null)
                    {
                        Adornments.Add(this.CreateAdornment(this, xValues[i], toggledYValues[i], 0, double.IsNaN(currHeight) ? 1 - height[i] / 2 : currHeight + coef * height[i] / 2));
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// To calculate the segments if the pyramid mode is linear
        /// </summary>
        private void CalculateLinearSegments(double sumValues, double gapRatio, int count, List <double> xValues)
        {
            var toggledYValues = YValues.ToList();

            if (ToggledLegendIndex.Count > 0)
            {
                toggledYValues = GetYValues();
            }
            currY = 0;
            double coef = 1d / (sumValues * (1 + gapRatio / (1 - gapRatio)));

            for (int i = 0; i < count; i++)
            {
                double height = 0;
                if (!double.IsNaN(YValues[i]))
                {
                    height = coef * Math.Abs(double.IsNaN(toggledYValues[i]) ? 0 : toggledYValues[i]);
                    PyramidSegment pyramidSegment = new PyramidSegment(currY, height, this.ExplodeOffset, this, i == ExplodeIndex || this.ExplodeAll ? true : false);
                    pyramidSegment.Item  = ActualData[i];
                    pyramidSegment.XData = xValues[i];
                    pyramidSegment.YData = Math.Abs(YValues[i]);
                    if (ToggledLegendIndex.Contains(i))
                    {
                        pyramidSegment.IsSegmentVisible = false;
                    }
                    else
                    {
                        pyramidSegment.IsSegmentVisible = true;
                    }
                    this.Segments.Add(pyramidSegment);
                    currY += (gapRatio / (count - 1)) + height;
                    if (AdornmentsInfo != null)
                    {
                        Adornments.Add(this.CreateAdornment(this, xValues[i], toggledYValues[i], 0, double.IsNaN(currY) ? 1 - height / 2 : currY - height / 2));
                        Adornments[Segments.Count - 1].Item = ActualData[i];
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Creates the segments of AreaSeries.
        /// </summary>
        public override void CreateSegments()
        {
            List <double> yValues   = new List <double>();
            bool          isGrouped = (ActualXAxis is CategoryAxis && !(ActualXAxis as CategoryAxis).IsIndexed);
            List <double> xValues   = null;

            if (isGrouped)
            {
                xValues = GroupedXValuesIndexes;
            }
            else
            {
                xValues = GetXValues();
            }
            yValues = YValues.ToList();

            if (AdornmentsInfo != null)
            {
                ClearUnUsedAdornments(this.DataCount);
            }

            if (isGrouped)
            {
                if (xValues != null && xValues.Count > 1)
                {
                    Segments.Clear();
                    Adornments.Clear();
                    if (Segment == null || Segments.Count == 0)
                    {
                        Segment = new AreaSegment(xValues, GroupedSeriesYValues[0] as List <double>, this, ActualData);
                        Segment.SetData(xValues, GroupedSeriesYValues[0] as List <double>);
                        Segments.Add(Segment);
                    }
                }

                if (AdornmentsInfo != null)
                {
                    AddAreaAdornments(GroupedSeriesYValues[0]);
                }
            }
            else
            {
                if (xValues != null && xValues.Count > 1)
                {
                    if (Segment == null || Segments.Count == 0)
                    {
                        Segment = new AreaSegment(xValues, yValues, this, ActualData);
                        Segment.SetData(xValues, yValues);
                        Segments.Add(Segment);
                    }
                    else
                    {
                        Segment.Item = ActualData;
                        Segment.SetData(xValues, yValues);
                    }
                }

                if (AdornmentsInfo != null)
                {
                    AddAreaAdornments(YValues);
                }
            }
        }