A data series in a chart.
NuGet Package: DevExpress.Spreadsheet.Core
The Series class contains a group of associated data points of a chart. The visual representation of data points is determined by the Series.SeriesType. The type of the series is set when the series is created and can be changed later using the Series.ChangeType method. However, changing the type of one series may affect other series or the entire chart.
The Series objects for a particular chart are contained in the SeriesCollection collection. A collection of series for the entire chart is accessible by using the ChartObject.Series property. For the combination chart consisting of several views, you can use the ChartView.Series property to access the series for a specific view.
Series are created automatically when the chart is created using the ChartObject.SelectData method. The series type is the same as the type of the newly created chart.
You can also manually add series to a chart using the SeriesCollection.Add method of the series collection. The series type is the same as the type of the chart view (ChartView.ViewType) that owns the series collection.
The example below demonstrates how to add data series to a chart and change the cell range containing data for a specific series.
The code uses the SeriesCollection.Add method to create a series and add it to the ChartObject.Series collection. To specify series values contained in the worksheet range, create a ChartData object using the ChartData.FromRange method and assign it to the Series.Values property.
Worksheet worksheet = workbook.Worksheets["chartTask3"]; workbook.Worksheets.ActiveWorksheet = worksheet; // Create a chart and specify its location. Chart chart = worksheet.Charts.Add(ChartType.ColumnClustered); chart.TopLeftCell = worksheet.Cells["H2"]; chart.BottomRightCell = worksheet.Cells["N14"]; // Add series using a worksheet range as the data source. chart.Series.Add(worksheet["D2"], worksheet["B3:B6"], worksheet["D3:D6"]); chart.Series.Add(worksheet["F2"], worksheet["B3:B6"], worksheet["F3:F6"]); // Change the data range for the series values. chart.Series.Values = ChartData.FromRange(worksheet["E3:E6"]); // Specify the cell that is the source for the series name. chart.Series.SeriesName.SetReference(worksheet["E2"]);