Back to Devexpress

SeriesCollection.Add(ChartData, ChartData) Method

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

latest7.8 KB
Original Source

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.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

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

Parameters

NameTypeDescription
argumentsChartData

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

TypeDescription
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

csharp
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 });
vb
Dim worksheet As Worksheet = workbook.Worksheets(0)
workbook.Worksheets.ActiveWorksheet = worksheet
worksheet.Columns(0).WidthInCharacters = 2.0

' Create a chart and specify its location.
Dim chart As 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.
Dim series_of_literal As Series = 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.

wpf-spreadsheet-chart-api/CS/SpreadsheetWPFChartAPISamples/CodeExamples/CreationAndDataActions.cs#L95

csharp
// 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" },

winforms-spreadsheet-chart-api/CS/SpreadsheetChartAPISamples/CodeExamples/CreationAndDataActions.cs#L95

csharp
// 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" },

spreadsheet-document-api-chart-examples/CS/SpreadsheetDocServerChartAPISamples/CodeExamples/CreationAndDataActions.cs#L105

csharp
// 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" },

wpf-spreadsheet-chart-api/VB/SpreadsheetWPFChartAPISamples/CodeExamples/CreationAndDataActions.vb#L98

vb
' Add a series bound to a set of literal data.
Dim series_of_literal As Series = chart.Series.Add(New CellValue() { "Jan", "Feb", "Mar", "Apr", "May", "Jun" }, New CellValue() { 50, 100, 30, 104, 87, 150 })

winforms-spreadsheet-chart-api/VB/SpreadsheetChartAPISamples/CodeExamples/CreationAndDataActions.vb#L97

vb
' Add a series bound to a set of literal data.
Dim series_of_literal As Series = chart.Series.Add(New CellValue() { "Jan", "Feb", "Mar", "Apr", "May", "Jun" }, New CellValue() { 50, 100, 30, 104, 87, 150 })

spreadsheet-document-api-chart-examples/VB/SpreadsheetDocServerChartAPISamples/CodeExamples/CreationAndDataActions.vb#L97

vb
' Add a series bound to a set of literal data.
            Dim series_of_literal As Series = chart.Series.Add(New CellValue() {"Jan", "Feb", "Mar", "Apr", "May", "Jun"}, New CellValue() {50, 100, 30, 104, 87, 150})
#End Region ' #CreateChartWithLiteralData

See Also

SeriesCollection Interface

SeriesCollection Members

DevExpress.Spreadsheet.Charts Namespace