private static void OnSelectedIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ChartSeries series = d as ChartSeries; series.OnPropertyChanged("SelectedIndex"); if (series.ActualArea == null || series.ActualArea.SelectionBehaviour == null) { return; } if ((series.ActualArea as SfChart).SelectionBehaviour.SelectionStyle == SelectionStyle.Single) { series.SelectedIndexChanged((int)e.NewValue, (int)e.OldValue); } else if ((int)e.NewValue != -1) { series.SelectedSegmentsIndexes.Add((int)e.NewValue); } CircularSeriesBase circularseries = series as CircularSeriesBase; if (circularseries != null && !double.IsNaN(circularseries.GroupTo) && series.ActualArea.Legend != null) { series.ActualArea.UpdateLegend(series.ActualArea.Legend, false); } }
private static void OnGroupToPropertiesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { CircularSeriesBase series = d as CircularSeriesBase; if (series != null && series.ActualArea != null) { series.ActualArea.IsUpdateLegend = true; series.Segments.Clear(); series.UpdateArea(); } }
/// <summary> /// Updates the panel. /// </summary> /// <param name="finalSize"></param> internal void Update(Size finalSize) { bool canUpdate = !(Series is ISupportAxes); if (Series is ISupportAxes && Series.ActualXAxis != null && Series.ActualYAxis != null) { canUpdate = true; if (Series.Area != null) { Series.Area.ClearBuffer(); } } if (canUpdate) { IChartTransformer chartTransformer = Series.CreateTransformer(finalSize, true); if (Series is CircularSeriesBase) { CircularSeriesBase circularSeries = Series as CircularSeriesBase; Rect rect = ChartLayoutUtils.Subtractthickness(new Rect(new Point(), finalSize), Series.Margin); chartTransformer = Series.CreateTransformer(new Size(rect.Width, rect.Height), true); var pieSeries = circularSeries as PieSeries; double coefficient = pieSeries != null ? pieSeries.InternalPieCoefficient : (circularSeries as DoughnutSeries).InternalDoughnutCoefficient; double radius = coefficient * Math.Min(chartTransformer.Viewport.Width, chartTransformer.Viewport.Height) / 2; circularSeries.Center = circularSeries.GetActualCenter(new Point(chartTransformer.Viewport.Width * 0.5d, chartTransformer.Viewport.Height * 0.5d), radius); } Series.Pixels.Clear(); Series.bitmapPixels.Clear(); Series.bitmapRects.Clear(); foreach (ChartSegment segment in Series.Segments) { segment.Update(chartTransformer); } if (Series.CanAnimate && Series.Segments.Count > 0) { Series.Animate(); Series.CanAnimate = false; } if (Series.IsLoading) { Series.IsLoading = false; } } }
private static void OnStartAngleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { CircularSeriesBase series = d as CircularSeriesBase; if (series != null) { if (!double.IsNaN(series.GroupTo)) { OnGroupToPropertiesChanged(d, e); } else { series.UpdateArea(); } } }
/// <summary> /// Method used to set SegmentSelectionBrush to selectedindex chartsegment /// </summary> /// <param name="newIndex"/> /// <param name="oldIndex"/> protected internal override void SelectedIndexChanged(int newIndex, int oldIndex) { CircularSeriesBase circularseries = this as CircularSeriesBase; bool isGroupTo = circularseries != null && !double.IsNaN(circularseries.GroupTo); ChartSelectionChangedEventArgs chartSelectionChangedEventArgs; if (ActualArea != null && ActualArea.SelectionBehaviour != null) { ChartSegment selectedSegment = null, oldSegment = null; // Reset the oldIndex segment Interior if (ActualArea.SelectionBehaviour.SelectionStyle == SelectionStyle.Single) { if (SelectedSegmentsIndexes.Contains(oldIndex)) { SelectedSegmentsIndexes.Remove(oldIndex); } OnResetSegment(oldIndex); } if (oldIndex != -1 && oldIndex < ActualData.Count) { object oldItem = isGroupTo ? Segments[oldIndex].Item : ActualData[oldIndex]; oldSegment = Segments.Where(segment => segment.Item == oldItem).FirstOrDefault(); } if (newIndex >= 0 && ActualArea.GetEnableSegmentSelection()) { if (!SelectedSegmentsIndexes.Contains(newIndex)) { SelectedSegmentsIndexes.Add(newIndex); } if (Segments.Count == 0) { triggerSelectionChangedEventOnLoad = true; return; } if (newIndex < Segments.Count || newIndex < ActualData.Count) { // For adornment selection implementation if (adornmentInfo is ChartAdornmentInfo && adornmentInfo.HighlightOnSelection) { UpdateAdornmentSelection(newIndex); } // Set the SegmentSelectionBrush to newIndex segment Interior if (this is ISegmentSelectable) { object newItem = isGroupTo ? Segments[newIndex].Item : ActualData[newIndex]; selectedSegment = Segments.Where(segment => segment.Item == newItem).FirstOrDefault(); if (selectedSegment != null) { if (this.SegmentSelectionBrush != null) { selectedSegment.BindProperties(); } selectedSegment.IsSelectedSegment = true; } } } if (newIndex < Segments.Count || newIndex < ActualData.Count) { chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs() { SelectedSegment = selectedSegment, SelectedSegments = Area.SelectedSegments, SelectedSeries = this, SelectedIndex = newIndex, PreviousSelectedIndex = oldIndex, PreviousSelectedSegment = oldSegment, NewPointInfo = selectedSegment != null ? selectedSegment.Item : null, OldPointInfo = oldSegment != null ? oldSegment.Item : null, PreviousSelectedSeries = null, IsSelected = true }; if (this.ActualArea.PreviousSelectedSeries != null && oldIndex != -1) { chartSelectionChangedEventArgs.PreviousSelectedSeries = this.ActualArea.PreviousSelectedSeries; } (ActualArea as SfChart).OnSelectionChanged(chartSelectionChangedEventArgs); PreviousSelectedIndex = newIndex; } } else if (newIndex == -1) { chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs() { SelectedSegment = null, SelectedSegments = Area.SelectedSegments, SelectedSeries = null, SelectedIndex = newIndex, PreviousSelectedIndex = oldIndex, PreviousSelectedSegment = oldSegment, NewPointInfo = null, OldPointInfo = oldSegment.Item, PreviousSelectedSeries = this, IsSelected = false }; (ActualArea as SfChart).OnSelectionChanged(chartSelectionChangedEventArgs); PreviousSelectedIndex = newIndex; } } }