ChartCollection.Add(ChartType, CellRange) 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.v24.1.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
Parameters
Name | Type | Description |
---|---|---|
chartType | ChartType | A ChartType enumeration member specifying the chart type. |
range | CellRange | A CellRange containing chart data. |
Returns
Type | Description |
---|---|
Chart | A Chart object that is the chart embedded in a worksheet. |
Example
The example below demonstrates how to create a 3-D pie chart using the ChartCollection.Add method overload that allows you to specify a CellRange containing chart data.
Worksheet worksheet = workbook.Worksheets["chartTask1"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Create a pie chart and specify its location.
Chart 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, CellRange) 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.