Back to Devexpress

ChartCollection Interface

officefileapi-devexpress-dot-spreadsheet-dot-charts-84f02333.md

latest3.1 KB
Original Source

ChartCollection Interface

A collection of Chart objects in a worksheet.

Namespace : DevExpress.Spreadsheet.Charts

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
public interface ChartCollection :
    ISimpleCollection<Chart>,
    IEnumerable<Chart>,
    IEnumerable,
    ICollection
vb
Public Interface ChartCollection
    Inherits ISimpleCollection(Of Chart),
             IEnumerable(Of Chart),
             IEnumerable,
             ICollection

The following members return ChartCollection objects:

Remarks

Use the Worksheet.Charts property to return the ChartCollection collection.

Use the ChartCollection.Add method to create a new chart and add it to the workbook. The following example adds a new embedded chart to the active worksheet and places the new chart above the cells in the range E2:K15.

The example below demonstrates how to create a 3-D pie chart using the ChartCollection.Add method overload that enables you to specify a CellRange containing chart data.

View Example

csharp
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;
vb
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

See Also

ChartCollection Members

How to: Create and Modify a Chart

DevExpress.Spreadsheet.Charts Namespace