/// <summary>
 /// Method used to get the given adornment is selected or not
 /// </summary>
 /// <param name="adornment"></param>
 /// <returns></returns>
 private static bool IsAdornmentSelected(ChartAdornment adornment)
 {
     return(adornment.Series.SelectedSegmentsIndexes.Contains(adornment.Series.ActualData.IndexOf(adornment.Item)) &&
            adornment.Series is ISegmentSelectable && adornment.Series.adornmentInfo.HighlightOnSelection &&
            (adornment.Series as ISegmentSelectable).SegmentSelectionBrush != null &&
            (adornment.Series.adornmentInfo.UseSeriesPalette || adornment.Background != null));
 }
        /// <summary>
        /// Modifies the source data before passing it to the target for display in the UI.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="language"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            ChartAdornment adornment = value as ChartAdornment;

            if (adornment == null)
            {
                return(value);
            }

            ChartSeriesBase series = adornment.Series;
            ChartBase       area   = series.ActualArea;

            var selectableSegment = series as ISegmentSelectable;

            if (area.SelectedSeriesCollection.Contains(series) &&
                area.GetSeriesSelectionBrush(series) != null && series is ChartSeries &&
                series.adornmentInfo.HighlightOnSelection && area.GetEnableSeriesSelection())
            {
                return(area.GetSeriesSelectionBrush(series));
            }
            else if (series.SelectedSegmentsIndexes.Contains(series.ActualData.IndexOf(adornment.Item)) &&
                     selectableSegment != null && series.adornmentInfo.HighlightOnSelection &&
                     selectableSegment.SegmentSelectionBrush != null)
            {
                return(selectableSegment.SegmentSelectionBrush);
            }
            else
            {
                return(adornment.BorderBrush);
            }
        }
Exemple #3
0
        private void AddBoxWhiskerAdornments(DoubleRange sbsInfo, double xValue, double minimum, double maximum, double x1, double median, double lowerQuartile, double upperQuartile, List <double> outliers, int index)
        {
            if (AdornmentsInfo != null)
            {
                ChartAdornment adornment = null;
                var            sbsMedian = sbsInfo.Delta / 2;

                adornment = this.CreateAdornment(this, xValue, minimum, x1 + sbsMedian, minimum);
                adornment.ActualLabelPosition = bottomLabelPosition;
                adornment.Item = ActualData[index];
                Adornments.Add(adornment);

                adornment = this.CreateAdornment(this, xValue, lowerQuartile, x1 + sbsMedian, lowerQuartile);
                adornment.ActualLabelPosition = bottomLabelPosition;
                adornment.Item = ActualData[index];
                Adornments.Add(adornment);

                adornment = this.CreateAdornment(this, xValue, median, x1 + sbsMedian, median);
                adornment.ActualLabelPosition = topLabelPosition;
                adornment.Item = ActualData[index];
                Adornments.Add(adornment);

                adornment = this.CreateAdornment(this, xValue, upperQuartile, x1 + sbsMedian, upperQuartile);
                adornment.ActualLabelPosition = topLabelPosition;
                adornment.Item = ActualData[index];
                Adornments.Add(adornment);

                adornment = this.CreateAdornment(this, xValue, maximum, x1 + sbsMedian, maximum);
                adornment.ActualLabelPosition = topLabelPosition;
                adornment.Item = ActualData[index];
                Adornments.Add(adornment);
            }
        }
        /// <summary>
        /// Modifies the source data before passing it to the target for display in the UI.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="language"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            ChartAdornment adornment = value as ChartAdornment;

            if (adornment == null)
            {
                return(value);
            }
            if (adornment.CanHideLabel)
            {
                return(new SolidColorBrush(Colors.Transparent));
            }
            else if (adornment.Series.ActualArea.SelectedSeriesCollection.Contains(adornment.Series) &&
                     adornment.Series.ActualArea.GetSeriesSelectionBrush(adornment.Series) != null &&
                     adornment.Series.adornmentInfo.HighlightOnSelection && adornment.Series is ChartSeries &&
                     adornment.Series.ActualArea.GetEnableSeriesSelection() &&
                     (adornment.Series.adornmentInfo.UseSeriesPalette || adornment.Background != null))
            {
                return(adornment.Series.ActualArea.GetSeriesSelectionBrush(adornment.Series));
            }
            else if (IsAdornmentSelected(adornment))
            {
                return((adornment.Series as ISegmentSelectable).SegmentSelectionBrush);
            }
            else if (adornment.Series.adornmentInfo.UseSeriesPalette && adornment.Background == null)
            {
                return(adornment.Interior);
            }

            return(adornment.Background);
        }
Exemple #5
0
        internal void Dispose()
        {
            m_symbolPresenter.SetValue(ContentPresenter.ContentTemplateProperty, null);
            m_symbolPresenter.SetValue(ContentPresenter.ContentProperty, null);

            this.adornment         = null;
            this.PredefinedSymbol  = null;
            this.m_symbolPresenter = null;
        }
        /// <summary>
        /// Modifies the source data before passing it to the target for display in the UI.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="language"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            ChartAdornment adornment = value as ChartAdornment;

            if (adornment == null)
            {
                return(value);
            }

            return(adornment.GetTextContent());
        }
        /// <summary>
        /// Method implementation for Create Adornments
        /// </summary>
        /// <param name="series"></param>
        /// <param name="xVal"></param>
        /// <param name="yVal"></param>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        /// <returns></returns>
        protected virtual ChartAdornment CreateAdornment(AdornmentSeries series, double xVal, double yVal, double xPos, double yPos)
        {
            ChartAdornment adornment = new ChartAdornment(xVal, yVal, xPos, yPos, series);

            adornment.XData  = xVal;
            adornment.YData  = yVal;
            adornment.XPos   = xPos;
            adornment.YPos   = yPos;
            adornment.Series = series;
            return(adornment);
        }
        /// <summary>
        /// Modifies the source data before passing it to the target for display in the UI.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="language"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            ChartAdornment adornment = value as ChartAdornment;

            if (adornment == null)
            {
                return(new SolidColorBrush(Colors.White));
            }
            if (adornment.Foreground == foregroundBrush)
            {
                return(new SolidColorBrush(Colors.White));
            }

            return(adornment.Foreground);
        }
Exemple #9
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;
                }
            }
        }
Exemple #10
0
        /// <summary>
        /// Sets the binding between the adornment symbol and <see cref="ChartAdornmentInfo"/>
        /// </summary>
        /// <param name="adornment"></param>
        private void SetContentBinding(ChartAdornment adornment)
        {
            ChartAdornmentInfoBase adornmentInfo = adornment.Series.adornmentInfo;

            if (adornmentInfo.ShowMarker)
            {
                this.SetBinding(ChartAdornmentContainer.SymbolProperty
                                , CreateAdormentBinding("Symbol", adornmentInfo));

                this.PredefinedSymbol.SetBinding(Control.HeightProperty
                                                 , CreateAdormentBinding("SymbolHeight", adornmentInfo));

                this.PredefinedSymbol.SetBinding(Control.WidthProperty
                                                 , CreateAdormentBinding("SymbolWidth", adornmentInfo));

                if (adornment.Series is ChartSeries &&
                    adornment.Series.ActualArea.SelectedSeriesCollection.Contains(adornment.Series) &&
                    adornmentInfo.HighlightOnSelection &&
                    adornment.Series.ActualArea.GetSeriesSelectionBrush(adornment.Series) != null &&
                    adornment.Series.ActualArea.GetEnableSeriesSelection())
                {
                    this.PredefinedSymbol.SetBinding(Control.BackgroundProperty
                                                     , CreateAdormentBinding("SeriesSelectionBrush", adornment.Series));
                }
                else if (adornment.Series is ISegmentSelectable &&
                         adornment.Series.SelectedSegmentsIndexes.Contains(adornment.Series.ActualData.IndexOf(adornment.Item)) &&
                         adornmentInfo.HighlightOnSelection &&
                         adornment.Series.ActualArea.GetEnableSegmentSelection() &&
                         (adornment.Series as ISegmentSelectable).SegmentSelectionBrush != null)
                {
                    this.PredefinedSymbol.SetBinding(Control.BackgroundProperty
                                                     , CreateAdormentBinding("SegmentSelectionBrush", adornment.Series));
                }
                else if (adornmentInfo.SymbolInterior == null)
                {
                    this.PredefinedSymbol.SetBinding(SymbolControl.BackgroundProperty
                                                     , CreateAdormentBinding("Interior", adornment));
                }
                else
                {
                    this.PredefinedSymbol.SetBinding(Control.BackgroundProperty
                                                     , CreateAdormentBinding("SymbolInterior", adornmentInfo));
                }

                if (adornment.Series is ChartSeries &&
                    adornment.Series.ActualArea.SelectedSeriesCollection.Contains(adornment.Series) &&
                    adornmentInfo.HighlightOnSelection &&
                    adornment.Series.ActualArea.GetSeriesSelectionBrush(adornment.Series) != null &&
                    adornment.Series.ActualArea.GetEnableSeriesSelection())
                {
                    this.PredefinedSymbol.SetBinding(Control.BorderBrushProperty
                                                     , CreateAdormentBinding("SeriesSelectionBrush", adornment.Series));
                }
                else if (adornment.Series is ISegmentSelectable &&
                         adornment.Series.SelectedSegmentsIndexes.Contains(adornment.Series.ActualData.IndexOf(adornment.Item)) &&
                         adornmentInfo.HighlightOnSelection &&
                         adornment.Series.ActualArea.GetEnableSegmentSelection() &&
                         (adornment.Series as ISegmentSelectable).SegmentSelectionBrush != null)
                {
                    this.PredefinedSymbol.SetBinding(Control.BorderBrushProperty
                                                     , CreateAdormentBinding("SegmentSelectionBrush", adornment.Series));
                }
                else
                {
                    this.PredefinedSymbol.SetBinding(Control.BorderBrushProperty
                                                     , CreateAdormentBinding("SymbolStroke", adornmentInfo));
                }

                if (adornmentInfo.SymbolTemplate != null)
                {
                    this.m_symbolPresenter.SetBinding(ContentPresenter.ContentTemplateProperty
                                                      , CreateAdormentBinding("SymbolTemplate", adornmentInfo));
                }

                this.m_symbolPresenter.SetBinding(ContentPresenter.ContentProperty
                                                  , CreateAdormentBinding("", adornment));
            }
        }
Exemple #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChartAdornmentContainer"/> class.
 /// </summary>
 /// <param name="adornment"></param>
 public ChartAdornmentContainer(ChartAdornment adornment)
 {
     PredefinedSymbol = new SymbolControl();
     Adornment        = adornment;
 }
Exemple #12
0
        internal override void UpdateTooltip(object originalSource)
        {
            if (ShowTooltip)
            {
                FrameworkElement element      = originalSource as FrameworkElement;
                object           chartSegment = null;

                if (element != null)
                {
                    if (element.Tag is ChartSegment)
                    {
                        chartSegment = element.Tag;
                    }
                    else if (element.DataContext is ChartSegment && !(element.DataContext is ChartAdornment))
                    {
                        chartSegment = element.DataContext;
                    }
                    else
                    {
                        int index = ChartExtensionUtils.GetAdornmentIndex(element);
                        if (index != -1)
                        {
                            if (index < Segments.Count)
                            {
                                chartSegment = Segments[index];
                            }
                            else if (Segments.Count > 0)
                            {
                                chartSegment = Segments[index - 1];
                            }
                            else if (index < Adornments.Count)
                            {
                                // WPF-28526- Tooltip not shown when set the single data point with adornments for continuous series.
                                ChartAdornment adornment = Adornments[index];
                                chartSegment = new StepLineSegment()
                                {
                                    X1Value = adornment.XData,
                                    Y1Value = adornment.YData,
                                    X1Data  = adornment.XData,
                                    Y1Data  = adornment.YData,
                                    X1      = adornment.XData,
                                    Y1      = adornment.YData,
                                    XData   = adornment.XData,
                                    YData   = adornment.YData,
                                    Item    = adornment.Item
                                };
                            }
                        }
                    }
                }

                if (chartSegment == null)
                {
                    return;
                }

                SetTooltipDuration();
                var canvas = this.Area.GetAdorningCanvas();
                if (this.Area.Tooltip == null)
                {
                    this.Area.Tooltip = new ChartTooltip();
                }
                var chartTooltip = this.Area.Tooltip as ChartTooltip;
                if (chartTooltip != null)
                {
                    var lineSegment = chartSegment as StepLineSegment;
                    if (canvas.Children.Count == 0 || (canvas.Children.Count > 0 && !IsTooltipAvailable(canvas)))
                    {
                        SetTooltipSegmentItem(lineSegment);
                        chartTooltip.Content = chartSegment;

                        if (ChartTooltip.GetInitialShowDelay(this) == 0)
                        {
                            canvas.Children.Add(chartTooltip);
                        }

                        chartTooltip.ContentTemplate = this.GetTooltipTemplate();
                        AddTooltip();

                        if (ChartTooltip.GetEnableAnimation(this))
                        {
                            SetDoubleAnimation(chartTooltip);
                            storyBoard.Children.Add(leftDoubleAnimation);
                            storyBoard.Children.Add(topDoubleAnimation);
                            Canvas.SetLeft(chartTooltip, chartTooltip.LeftOffset);
                            Canvas.SetTop(chartTooltip, chartTooltip.TopOffset);

                            _stopwatch.Start();
                        }
                        else
                        {
                            Canvas.SetLeft(chartTooltip, chartTooltip.LeftOffset);
                            Canvas.SetTop(chartTooltip, chartTooltip.TopOffset);
                            _stopwatch.Start();
                        }
                    }
                    else
                    {
                        foreach (var child in canvas.Children)
                        {
                            var tooltip = child as ChartTooltip;
                            if (tooltip != null)
                            {
                                chartTooltip = tooltip;
                            }
                        }

                        SetTooltipSegmentItem(lineSegment);
                        chartTooltip.Content         = chartSegment;
                        chartTooltip.ContentTemplate = this.GetTooltipTemplate();
                        AddTooltip();
#if NETFX_CORE
                        if (_stopwatch.ElapsedMilliseconds > 100)
                        {
#endif
                        if (ChartTooltip.GetEnableAnimation(this))
                        {
                            _stopwatch.Restart();

                            if (leftDoubleAnimation == null || topDoubleAnimation == null || storyBoard == null)
                            {
                                SetDoubleAnimation(chartTooltip);
                            }
                            else
                            {
                                leftDoubleAnimation.To = chartTooltip.LeftOffset;
                                topDoubleAnimation.To  = chartTooltip.TopOffset;
                                storyBoard.Begin();
                            }
                        }
                        else
                        {
                            Canvas.SetLeft(chartTooltip, chartTooltip.LeftOffset);
                            Canvas.SetTop(chartTooltip, chartTooltip.TopOffset);
                        }
#if NETFX_CORE
                    }
                    else if (EnableAnimation == false)
                    {
                        Canvas.SetLeft(chartTooltip, chartTooltip.LeftOffset);
                        Canvas.SetTop(chartTooltip, chartTooltip.TopOffset);
                    }
#endif
                    }
                }
            }
        }