Skip to main content

SeriesCollection.Add(ChartData, ChartData) Method

Appends a new series with the specified argument and value data to the collection.

Namespace: DevExpress.Spreadsheet.Charts

Assembly: DevExpress.Spreadsheet.v24.1.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

Series Add(
    ChartData arguments,
    ChartData values
)

Parameters

Name Type Description
arguments ChartData

A ChartData object that is the data to plot as series arguments.

values ChartData

A ChartData object that is the data to plot as series values.

Returns

Type Description
Series

A Series object that is the newly created series.

Remarks

You can pass objects of various types to the Add method because the ChartData type enables implicit conversions from common types such as string, integer, double, DateTime, char, bool and specific types such as CellValue and two-dimensional CellValue array.

The Add method adds a series with the same Series.SeriesType as the ChartView.ViewType of the chart view to which a series collection belongs. If the ChartObject.Series property is used to obtain a series collection and the chart is composed of several views, the type of the chart view with the highest index is used.

View Example

Worksheet worksheet = workbook.Worksheets[0];
workbook.Worksheets.ActiveWorksheet = worksheet;
worksheet.Columns[0].WidthInCharacters = 2.0;

// Create a chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.ColumnClustered);
chart.TopLeftCell = worksheet.Cells["B2"];
chart.BottomRightCell = worksheet.Cells["H15"];

// Add a series bound to a set of literal data.
Series series_of_literal = chart.Series.Add(
    new CellValue[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun" },
    new CellValue[] { 50, 100, 30, 104, 87, 150 });

The following code snippets (auto-collected from DevExpress Examples) contain references to the Add(ChartData, ChartData) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also