Ejemplo 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));
                    }
                }
            }
        }
Ejemplo 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];
                    }
                }
            }
        }