예제 #1
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(ISeries series)
        {
            AggregatedObservableCollection <object> legendItemsList = LegendItems as AggregatedObservableCollection <object>;

            legendItemsList.ChildCollections.Remove(series.LegendItems);

            series.SeriesHost = null;
        }
예제 #2
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(ISeries series)
        {
            series.SeriesHost = this;

            AggregatedObservableCollection <object> chartLegendItems = this.LegendItems as AggregatedObservableCollection <object>;
            int indexOfSeries = this.Series.IndexOf(series);

            chartLegendItems.ChildCollections.Insert(indexOfSeries, series.LegendItems);
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the Chart class.
        /// </summary>
        public Chart()
        {
            DefaultStyleKey = typeof(Chart);
            // Create the backing collection for Series
            UniqueObservableCollection <ISeries> series = new UniqueObservableCollection <ISeries>();

            series.CollectionChanged += SeriesCollectionChanged;
            _series = series;

            // Create the backing collection for Axes
            UniqueObservableCollection <IAxis> axes = new UniqueObservableCollection <IAxis>();

            _axes = axes;

            ObservableCollection <IAxis> actualAxes = new SeriesHostAxesCollection(this, axes);

            actualAxes.CollectionChanged += ActualAxesCollectionChanged;
            this.InternalActualAxes       = actualAxes;
            this.ActualAxes = new ReadOnlyCollection <IAxis>(InternalActualAxes);

            // Create collection for LegendItems
            LegendItems = new AggregatedObservableCollection <object>();

            ChartAreaChildren = new AggregatedObservableCollection <UIElement>();
            ChartAreaChildren.ChildCollections.Add(_edgeAxes);
            ChartAreaChildren.ChildCollections.Add(_backgroundElements);
            ChartAreaChildren.ChildCollections.Add(Series);
            ChartAreaChildren.ChildCollections.Add(_foregroundElements);

            _chartAreaChildrenListAdapter.Collection = ChartAreaChildren;

            // Create a dispenser
            ResourceDictionaryDispenser = new ResourceDictionaryDispenser();
            ResourceDictionaryDispenser.ResourceDictionariesChanged += delegate
            {
                OnResourceDictionariesChanged(EventArgs.Empty);
            };
        }