示例#1
0
        /// <summary>
        /// Adds a series to the plot area and injects chart services.
        /// </summary>
        /// <param name="series">The series to add to the plot area.</param>
        private void AddSeriesToPlotArea(Series series)
        {
            series.SeriesHost = this;
            AggregatedObservableCollection<UIElement> chartLegendItems = this.LegendItems as AggregatedObservableCollection<UIElement>;

            int indexOfSeries = this.Series.IndexOf(series);
            chartLegendItems.ChildCollections.Insert(indexOfSeries, series.LegendItems);

            ISeriesHost host = series as ISeriesHost;
            if (host != null)
            {
                host.GlobalSeriesIndexesInvalidated += OnChildSeriesGlobalSeriesIndexesInvalidated;
            }
        }
示例#2
0
        /// <summary>
        /// Signals to the Chart that a Series no longer needs to use the axis 
        /// within this series host.
        /// </summary>
        /// <param name="series">The Series object that no longer needs to use 
        /// the axis.</param>
        /// <param name="axis">The axis that the Series no longer needs to use.
        /// </param>
        void ISeriesHost.UnregisterWithAxis(Series series, IAxis axis)
        {
            if (series == null)
            {
                throw new ArgumentNullException("series");
            }
            if (axis == null)
            {
                throw new ArgumentNullException("axis");
            }
            if (!ActualAxes.Contains(axis))
            {
                throw new InvalidOperationException(Properties.Resources.Chart_UnregisterWithSeries_OneAxisCannotBeUsedByMultipleCharts);
            }

            axis.Unregister(series);
            // If axis is no longer used and is not in external axes collection
            if (!axis.IsUsed && !Axes.Contains(axis))
            {
                InternalActualAxes.Remove(axis);
            }
        }
示例#3
0
        /// <summary>
        /// Removes a series from the plot area.
        /// </summary>
        /// <param name="series">The series to remove from the plot area.
        /// </param>
        private void RemoveSeriesFromPlotArea(Series series)
        {
            AggregatedObservableCollection<UIElement> legendItemsList = LegendItems as AggregatedObservableCollection<UIElement>;
            legendItemsList.ChildCollections.Remove(series.LegendItems);

            ISeriesHost host = series as ISeriesHost;
            if (host != null)
            {
                host.GlobalSeriesIndexesInvalidated -= OnChildSeriesGlobalSeriesIndexesInvalidated;
            }
            series.SeriesHost = null;
        }
示例#4
0
        /// <summary>
        /// Signals to the ISeriesHost that a series would like to use an axis.
        /// </summary>
        /// <param name="series">The series that would like to use the axis.
        /// </param>
        /// <param name="axis">The axis the series would like to use.</param>
        void ISeriesHost.RegisterWithAxis(Series series, IAxis axis)
        {
            if (series == null)
            {
                throw new ArgumentNullException("series");
            }
            if (axis == null)
            {
                throw new ArgumentNullException("axis");
            }

            axis.Register(series);
            if (!InternalActualAxes.Contains(axis))
            {
                InternalActualAxes.Add(axis);
            }
        }
示例#5
0
 public static IList<DataPoint> GetDataPointsForSeries(Series series)
 {
     return series.GetVisualChildren().OfType<DataPoint>().Where(dataPoint => dataPoint.Parent.GetType() == typeof(Canvas)).ToList();
 }