A newer version of this page is available. Switch to the current version.

Series Class

Represents an individual series within a chart control.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v18.2.dll

Declaration

[TypeConverter(typeof(SeriesTypeConverter))]
public class Series :
    SeriesBase,
    ISupportInitialize,
    ICustomTypeDescriptor,
    ISeries,
    ISeriesBase,
    ISeriesPointFactory,
    IXtraSerializable,
    ISupportID,
    IDataSourceChangedEventHandlerProvider
<TypeConverter(GetType(SeriesTypeConverter))>
Public Class Series
    Inherits SeriesBase
    Implements ISupportInitialize,
               ICustomTypeDescriptor,
               ISeries,
               ISeriesBase,
               ISeriesPointFactory,
               IXtraSerializable,
               ISupportID,
               IDataSourceChangedEventHandlerProvider

Remarks

The Series class defines the functionality of individual series objects within a chart control.

In addition to the settings inherited from the base SeriesBase class, the Series class exposes the properties which allow you to define a series name (Series.Name), specify its data source (Series.DataSource) and customize its data points (Series.Points).

The most important characteristic of a series is its view type, which determines the particular visual representation of data.

Series can be created either at design time or in code, in the following two ways.

  • Manually, by adding individual items to the ChartControl.Series collection, represented by an object of the SeriesCollection type. This collection allows you to manipulate its items by adding new or removing existing series objects. Then, a particular Series object can be accessed within the collection using indexer notation (see the SeriesCollection.Item property).
  • Automatically, based on the chart's data source, by specifying common series settings via the ChartControl.SeriesTemplate property. Note that series created in this way are not stored in the ChartControl.Series collection.

For more information on using both these approaches, refer to Create a Series Manually .

Note that the sequence in which series are drawn corresponds to the order they have in the collection.

For more information, refer to Series.

Examples

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

See Also