Skip to main content

SeriesCollection Class

Represents a collection that stores individual series within a chart control.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v24.2.dll

Declaration

public class SeriesCollection :
    DisposableChartCollectionBase,
    IOwnedElement,
    ICollection<ISeries>,
    IEnumerable<ISeries>,
    IEnumerable

Remarks

Data series which are defined explicitly are maintained by a chart control within its ChartControl.Series collection. This collection is represented by the SeriesCollection class. The properties and methods exposed by the SeriesCollection class can be used to perform common collection operations such as adding new or deleting existing items. Each item of the collection is represented by a Series object. Individual series can be accessed using indexer notation.

Note that series which are bound to data at the level of a chart control (in particular, using the ChartControl.DataSource, ChartControl.SeriesDataMember and both the SeriesBase.ArgumentDataMember and SeriesBase.ValueDataMembers properties) are not presented within a collection of the SeriesCollection type. In order to access such series use the CustomDrawSeriesEventArgsBase.Series property of the ChartControl.CustomDrawSeries or ChartControl.CustomDrawSeriesPoint events. In order to perform centralized customization of such series use the settings which are available via the ChartControl.SeriesTemplate property.

Example

The following example demonstrates how to create a ChartControl with two series of the SideBySideBarSeriesView type, and add this chart to a form at runtime. Before proceeding with this example, first create a Windows Forms Application in Visual Studio, and include all necessary assemblies to the References list of your project.

Then, add the following code to the Form.Load event handler.

using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ...

namespace SideBySideBar2D {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {
            // Create an empty chart.
            ChartControl sideBySideBarChart = new ChartControl();

            // Create the first side-by-side bar series and add points to it.
            Series series1 = new Series("Side-by-Side Bar Series 1", ViewType.Bar);
            series1.Points.Add(new SeriesPoint("A",  10));
            series1.Points.Add(new SeriesPoint("B", 12));
            series1.Points.Add(new SeriesPoint("C", 14));
            series1.Points.Add(new SeriesPoint("D", 17));

            // Create the second side-by-side bar series and add points to it.
            Series series2 = new Series("Side-by-Side Bar Series 2", ViewType.Bar);
            series2.Points.Add(new SeriesPoint("A", 15));
            series2.Points.Add(new SeriesPoint("B", 18));
            series2.Points.Add(new SeriesPoint("C", 25));
            series2.Points.Add(new SeriesPoint("D", 33));

            // Add the series to the chart.
            sideBySideBarChart.Series.Add(series1);
            sideBySideBarChart.Series.Add(series2);

            // Hide the legend (if necessary).
            sideBySideBarChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;

            // Rotate the diagram (if necessary).
            ((XYDiagram)sideBySideBarChart.Diagram).Rotated = true;

            // Add a title to the chart (if necessary).
            ChartTitle chartTitle1 = new ChartTitle();
            chartTitle1.Text = "Side-by-Side Bar Chart";
            sideBySideBarChart.Titles.Add(chartTitle1);

            // Add the chart to the form.
            sideBySideBarChart.Dock = DockStyle.Fill;
            this.Controls.Add(sideBySideBarChart);
        }

    }
}

Inheritance

Object
CollectionBase
ChartCollectionBase
DevExpress.XtraCharts.DisposableChartCollectionBase
SeriesCollection
See Also