예제 #1
0
        private static void OnMinWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            FunnelSeries funnelSeries = d as FunnelSeries;

            if (funnelSeries != null && funnelSeries.Area != null)
            {
                funnelSeries.Area.ScheduleUpdate();
            }
        }
예제 #2
0
        private static void OnFunnelModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            FunnelSeries funnelSeries = d as FunnelSeries;

            if (funnelSeries != null && funnelSeries.Area != null)
            {
                funnelSeries.Area.IsUpdateLegend = true;
                funnelSeries.Area.ScheduleUpdate();
            }
        }
예제 #3
0
 /// <summary>
 /// Defines the funnel path
 /// </summary>
 /// <param name="y"></param>
 /// <param name="height"></param>
 /// <param name="funnelSeries"></param>
 /// <param name="isExploded"></param>
 public FunnelSegment(double y, double height, FunnelSeries funnelSeries, bool isExploded)
 {
     base.Series     = funnelSeries;
     top             = y;
     bottom          = y + height;
     topRadius       = y / 2;
     bottomRadius    = (y + height) / 2;
     minimumWidth    = funnelSeries.MinWidth;
     explodedOffset  = funnelSeries.ExplodeOffset;
     this.IsExploded = isExploded;
 }
예제 #4
0
        /// <summary>
        /// Updates the segments based on its data point value. This method is not
        /// intended to be called explicitly outside the Chart but it can be overriden by
        /// any derived class.
        /// </summary>
        /// <param name="transformer">Reresents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param>
        public override void Update(IChartTransformer transformer)
        {
            if (!this.IsSegmentVisible)
            {
                segmentPath.Visibility = Visibility.Collapsed;
            }
            else
            {
                segmentPath.Visibility = Visibility.Visible;
            }

            Rect rect = new Rect(0, 0, transformer.Viewport.Width, transformer.Viewport.Height);

            if (rect.IsEmpty)
            {
                segmentPath.Data = null;
            }
            else
            {
                if (this.IsExploded)
                {
                    rect.X = this.explodedOffset;
                }
                PathFigure   figure = new PathFigure();
                FunnelSeries series = Series as FunnelSeries;
                if (series == null)
                {
                    return;
                }
                double minRadius = 0.5 * (1d - minimumWidth / rect.Width);
                bool   isBroken  = (topRadius >= minRadius) ^ (bottomRadius > minRadius) && series.FunnelMode == ChartFunnelMode.ValueIsHeight;
                double bottomY   = minRadius * (bottom - top) / (bottomRadius - topRadius);
                topRadius         = Math.Min(topRadius, minRadius);
                bottomRadius      = Math.Min(bottomRadius, minRadius);
                figure.StartPoint = new Point(rect.X + topRadius * rect.Width, rect.Y + top * rect.Height);
                Linesegment lineSeg1 = new Linesegment();
                lineSeg1.Point = new Point(rect.X + (1 - topRadius) * rect.Width, rect.Y + top * rect.Height);
                figure.Segments.Add(lineSeg1);
                if (isBroken)
                {
                    Linesegment lineSeg2 = new Linesegment();
                    lineSeg2.Point = new Point(rect.X + (1 - minRadius) * rect.Width, rect.Y + bottomY * rect.Height);
                    figure.Segments.Add(lineSeg2);
                }

                Linesegment lineSeg3 = new Linesegment();
                lineSeg3.Point = new Point(rect.X + (1 - bottomRadius) * rect.Width, rect.Y + bottom * rect.Height - series.StrokeThickness / 2);
                figure.Segments.Add(lineSeg3);
                Linesegment lineSeg4 = new Linesegment();
                lineSeg4.Point = new Point(rect.X + bottomRadius * rect.Width, rect.Y + bottom * rect.Height - series.StrokeThickness / 2);
                figure.Segments.Add(lineSeg4);

                if (isBroken)
                {
                    Linesegment lineSeg5 = new Linesegment();
                    lineSeg5.Point = new Point(rect.X + minRadius * rect.Width, rect.Y + bottomY * rect.Height);
                    figure.Segments.Add(lineSeg5);
                }

                figure.IsClosed              = true;
                this.segmentGeometry         = new PathGeometry();
                this.segmentGeometry.Figures = new PathFigureCollection()
                {
                    figure
                };
                segmentPath.Data = segmentGeometry;

                height = ((bottom - top) * rect.Height) / 2;
            }
        }