.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

ChartCollection.Add(ChartType) Method

Creates a chart of the specified type and adds it to the collection.

Namespace: DevExpress.Spreadsheet.Charts

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

Declaration

Chart Add(
    ChartType chartType
)

Parameters

Name Type Description
chartType ChartType

A ChartType enumeration member specifying the chart type.

Returns

Type Description
Chart

A Chart object that is the chart embedded in a worksheet.

Remarks

This example demonstrates how to create a chart using the ChartCollection.Add method and specify its data using the ChartObject.SelectData method.

The chart looks as follows.

SelectDataExample_ChartAuto

Dim worksheet As Worksheet = workbook.Worksheets("chartTask2")
workbook.Worksheets.ActiveWorksheet = worksheet

' Create a chart and specify its location.
Dim chartRowData As Chart = worksheet.Charts.Add(ChartType.ColumnStacked)
chartRowData.TopLeftCell = worksheet.Cells("E3")
chartRowData.BottomRightCell = worksheet.Cells("J12")

' Select chart data.
chartRowData.SelectData(worksheet("B3:C8"))
See Also