Ejemplo n.º 1
0
        /// <summary>
        /// To calculate the segments if the pyramid mode is vlaueisHeight.
        /// </summary>
        private void CalculateValueIsHeightSegments(IList <double> yValues, List <double> xValues, double sumValues, double gapRatio, int dataCount, int explodedIndex)
        {
            currY = 0d;
            double coefHeight = 1 / sumValues;
            double spacing    = gapRatio / (DataCount - 1);

            for (int i = DataCount - 1; i >= 0; i--)
            {
                double height = 0;
                if (!double.IsNaN(YValues[i]))
                {
                    height = Math.Abs(double.IsNaN(yValues[i]) ? 0 : yValues[i]) * coefHeight;
                    FunnelSegment funnelSegment = new FunnelSegment(currY, height, this, explodedIndex == i || this.ExplodeAll ? true : false);
                    funnelSegment.Item  = ActualData[i]; // WPF-14426 Funnel series legend and segment colour is changing while setting emptypoint
                    funnelSegment.XData = xValues[i];
                    funnelSegment.YData = YValues[i];

                    if (ToggledLegendIndex.Contains(i))
                    {
                        funnelSegment.IsSegmentVisible = false;
                    }
                    else
                    {
                        funnelSegment.IsSegmentVisible = true;
                    }
                    Segments.Add(funnelSegment);

                    if (AdornmentsInfo != null)
                    {
                        ChartAdornment adornment = (this.CreateAdornment(this, xValues[i], yValues[i], 0, double.IsNaN(currY) ? 0 : currY + (height + spacing) / 2));
                        adornment.Item = ActualData[i];
                        Adornments.Add(adornment);
                    }

                    currY += height + spacing;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// To calculate the segments if the pyramid mode is valueisWidth.
        /// </summary>
        private void CalculateValueIsWidthSegments(IList <double> yValues, List <double> xValues, double sumValues, double gapRatio, int count, int explodedIndex)
        {
            currY = 0d;
            if (ToggledLegendIndex.Count > 0)
            {
                count = YValues.Count - ToggledLegendIndex.Count;
            }
            double offset = 1d / (count - 1);
            double height = (1 - gapRatio) / (count - 1);

            for (int i = DataCount - 1; i > 0; i--)
            {
                if (!double.IsNaN(YValues[i]))
                {
                    double w1 = Math.Abs(YValues[i]);
                    double w2 = 0;
                    if (ToggledLegendIndex.Contains(i - 1))
                    {
                        for (int k = i - 2; k >= 0; k--)
                        {
                            if (!(ToggledLegendIndex.Contains(k)))
                            {
                                w2 = Math.Abs(YValues[k]);
                                break;
                            }
                        }
                    }
                    else
                    {
                        w2 = Math.Abs(YValues[i - 1]);
                    }

                    if (ToggledLegendIndex.Contains(i))
                    {
                        height = 0;
                        w2     = w1;
                    }
                    else
                    {
                        height = (1 - gapRatio) / (count - 1);
                    }

                    FunnelSegment funnelSegment = new FunnelSegment(currY, height, w1 / sumValues, w2 / sumValues, this, explodedIndex == i || this.ExplodeAll ? true : false);
                    funnelSegment.Item  = ActualData[i];
                    funnelSegment.XData = xValues[i];
                    funnelSegment.YData = YValues[i];

                    if (ToggledLegendIndex.Contains(i))
                    {
                        funnelSegment.IsSegmentVisible = false;
                    }
                    else
                    {
                        funnelSegment.IsSegmentVisible = true;
                    }

                    Segments.Add(funnelSegment);
                    if (AdornmentsInfo != null)
                    {
                        Adornments.Add(this.CreateAdornment(this, xValues[i], yValues[i], height, currY));
                        Adornments[Adornments.Count - 1].Item = ActualData[i];
                    }

                    if (!(ToggledLegendIndex.Contains(i)))
                    {
                        currY += offset;
                    }
                }
            }

            if (AdornmentsInfo != null && DataCount > 0)
            {
                Adornments.Add(this.CreateAdornment(this, xValues[0], yValues[0], height, currY));
                Adornments[Adornments.Count - 1].Item = ActualData[0];
            }
        }