ChartCollection.Add(ChartType, Range) Method
Creates a chart of the specified type with data from the specified range and adds the chart to the collection.
Namespace: DevExpress.Spreadsheet.Charts
Assembly: DevExpress.Spreadsheet.v18.2.Core.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
chartType | ChartType | A ChartType enumeration member specifying the chart type. |
range | Range | A Range containing chart data. |
Returns
Type | Description |
---|---|
Chart | A Chart object that is the chart embedded in a worksheet. |
Remarks
The example below demonstrates how to create a 3-D pie chart using the ChartCollection.Add method overload that enables you to specify a Range containing chart data.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-spreadsheet-chart-api-e5222
Dim worksheet As Worksheet = workbook.Worksheets("chartTask1")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a pie chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.Pie3D, worksheet("B2:C7"))
chart.TopLeftCell = worksheet.Cells("E2")
chart.BottomRightCell = worksheet.Cells("K15")
' Set the chart style.
chart.Style = ChartStyle.ColorGradient
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the Add(ChartType, Range) 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.