Excel.ChartCollection class
A collection of all the chart objects on a worksheet.
- Extends
Remarks
[Api set: ExcelApi 1.1]
Properties
| context | The request context associated with the object. This connects the add-in's process to the Office host application's process. |
| count | Returns the number of charts in the worksheet. |
| items | Gets the loaded child items in this collection. |
Methods
| add(type, source |
Creates a new chart. |
| add(type, source |
Creates a new chart. |
| get |
Returns the number of charts in the worksheet. |
| get |
Gets a chart using its name. If there are multiple charts with the same name, the first one will be returned. |
| get |
Gets a chart based on its position in the collection. |
| get |
Gets a chart using its name. If there are multiple charts with the same name, the first one will be returned. If the chart doesn't exist, then this method returns an object with its |
| load(options) | Queues up a command to load the specified properties of the object. You must call |
| load(property |
Queues up a command to load the specified properties of the object. You must call |
| load(property |
Queues up a command to load the specified properties of the object. You must call |
| toJSON() | Overrides the JavaScript |
Events
| on |
Occurs when a chart is activated. |
| on |
Occurs when a new chart is added to the worksheet. |
| on |
Occurs when a chart is deactivated. |
| on |
Occurs when a chart is deleted. |
Property Details
context
The request context associated with the object. This connects the add-in's process to the Office host application's process.
context: RequestContext;
Property Value
count
Returns the number of charts in the worksheet.
readonly count: number;
Property Value
number
Remarks
[Api set: ExcelApi 1.1]
items
Gets the loaded child items in this collection.
readonly items: Excel.Chart[];
Property Value
Method Details
add(type, sourceData, seriesBy)
Creates a new chart.
add(type: Excel.ChartType, sourceData: Range, seriesBy?: Excel.ChartSeriesBy): Excel.Chart;
Parameters
- type
- Excel.ChartType
Represents the type of a chart. See Excel.ChartType for details.
- sourceData
- Excel.Range
The Range object corresponding to the source data.
- seriesBy
- Excel.ChartSeriesBy
Optional. Specifies the way columns or rows are used as data series on the chart. See Excel.ChartSeriesBy for details.
Returns
Remarks
[Api set: ExcelApi 1.1]
add(type, sourceData, seriesBy)
Creates a new chart.
add(type: "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Boxwhisker" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel", sourceData: Range, seriesBy?: "Auto" | "Columns" | "Rows"): Excel.Chart;
Parameters
- type
-
"Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Boxwhisker" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel"
Represents the type of a chart. See Excel.ChartType for details.
- sourceData
- Excel.Range
The Range object corresponding to the source data.
- seriesBy
-
"Auto" | "Columns" | "Rows"
Optional. Specifies the way columns or rows are used as data series on the chart. See Excel.ChartSeriesBy for details.
Returns
Remarks
[Api set: ExcelApi 1.1]
getCount()
Returns the number of charts in the worksheet.
getCount(): OfficeExtension.ClientResult<number>;
Returns
OfficeExtension.ClientResult<number>
Remarks
[Api set: ExcelApi 1.4]
getItem(name)
Gets a chart using its name. If there are multiple charts with the same name, the first one will be returned.
getItem(name: string): Excel.Chart;
Parameters
- name
-
string
Name of the chart to be retrieved.
Returns
Remarks
[Api set: ExcelApi 1.1]
getItemAt(index)
Gets a chart based on its position in the collection.
getItemAt(index: number): Excel.Chart;
Parameters
- index
-
number
Index value of the object to be retrieved. Zero-indexed.
Returns
Remarks
[Api set: ExcelApi 1.1]
getItemOrNullObject(name)
Gets a chart using its name. If there are multiple charts with the same name, the first one will be returned. If the chart doesn't exist, then this method returns an object with its isNullObject property set to true. For further information, see *OrNullObject methods and properties.
getItemOrNullObject(name: string): Excel.Chart;
Parameters
- name
-
string
Name of the chart to be retrieved.
Returns
Remarks
[Api set: ExcelApi 1.4]
load(options)
Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.
load(options?: Excel.Interfaces.ChartCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.ChartCollection;
Parameters
Provides options for which properties of the object to load.
Returns
load(propertyNames)
Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.
load(propertyNames?: string | string[]): Excel.ChartCollection;
Parameters
- propertyNames
-
string | string[]
A comma-delimited string or an array of strings that specify the properties to load.
Returns
load(propertyNamesAndPaths)
Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.
load(propertyNamesAndPaths?: OfficeExtension.LoadOption): Excel.ChartCollection;
Parameters
- propertyNamesAndPaths
- OfficeExtension.LoadOption
propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.
Returns
toJSON()
Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that's passed to it.) Whereas the original Excel.ChartCollection object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.ChartCollectionData) that contains an "items" array with shallow copies of any loaded properties from the collection's items.
toJSON(): Excel.Interfaces.ChartCollectionData;
Returns
Event Details
onActivated
Occurs when a chart is activated.
readonly onActivated: OfficeExtension.EventHandlers<Excel.ChartActivatedEventArgs>;
Event Type
Remarks
[Api set: ExcelApi 1.8]
onAdded
Occurs when a new chart is added to the worksheet.
readonly onAdded: OfficeExtension.EventHandlers<Excel.ChartAddedEventArgs>;
Event Type
Remarks
[Api set: ExcelApi 1.8]
onDeactivated
Occurs when a chart is deactivated.
readonly onDeactivated: OfficeExtension.EventHandlers<Excel.ChartDeactivatedEventArgs>;
Event Type
Remarks
[Api set: ExcelApi 1.8]
onDeleted
Occurs when a chart is deleted.
readonly onDeleted: OfficeExtension.EventHandlers<Excel.ChartDeletedEventArgs>;
Event Type
Remarks
[Api set: ExcelApi 1.8]