Back to Devexpress

SeriesCollection.Add(CellRange, CellRange) Method

officefileapi-devexpress-dot-spreadsheet-dot-charts-dot-seriescollection-dot-add-x28-devexpress-dot-spreadsheet-dot-cellrange-devexpress-dot-spreadsheet-dot-cellrange-x29.md

latest3.7 KB
Original Source

SeriesCollection.Add(CellRange, CellRange) Method

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

Namespace : DevExpress.Spreadsheet.Charts

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
Series Add(
    CellRange arguments,
    CellRange values
)
vb
Function Add(
    arguments As CellRange,
    values As CellRange
) As Series

Parameters

NameTypeDescription
argumentsCellRange

A CellRange of cells containing data to plot as series arguments.

| | values | CellRange |

A CellRange of cells containing data to plot as series values.

|

Returns

TypeDescription
Series

A Series object that is the newly created series.

|

Remarks

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

csharp
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 chart series using worksheet ranges as the data sources.
chart.Series.Add(worksheet["D2"], worksheet["B3:B6"], worksheet["D3:D6"]);
chart.Series.Add(worksheet["F2"], worksheet["B3:B6"], worksheet["F3:F6"]);
vb
Dim worksheet As Worksheet = workbook.Worksheets("chartTask3")
workbook.Worksheets.ActiveWorksheet = worksheet

' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.ColumnClustered)
chart.TopLeftCell = worksheet.Cells("H2")
chart.BottomRightCell = worksheet.Cells("N14")

' Add chart series using worksheet ranges as the data sources.
chart.Series.Add(worksheet("D2"), worksheet("B3:B6"), worksheet("D3:D6"))
chart.Series.Add(worksheet("F2"), worksheet("B3:B6"), worksheet("F3:F6"))

See Also

SeriesCollection Interface

SeriesCollection Members

DevExpress.Spreadsheet.Charts Namespace