ChartGroups 对象 (Excel)ChartGroups object (Excel)

代表图表中用同一格式绘制的一个或多个数据系列。Represents one or more series plotted in a chart with the same format.

说明Remarks

ChartGroups 集合是指定图表中的所有 ChartGroup 对象的集合。A ChartGroups collection is a collection of all the ChartGroup objects in the specified chart. 一张图表包含一个或多个图表组,每个图表组包含一个或多个 序列 对象,每个数据系列包含一个或多个 对象。A chart contains one or more chart groups, each chart group contains one or more Series objects, and each series contains one or more Points objects. 例如,单张图表可能既包含折线图图表组,其中包含所有用折线图格式,绘制的数据系列也条形图图表组,其中包含所有用条形图格式绘制的数据系列。For example, a single chart might contain both a line chart group, containing all the series plotted with the line chart format, and a bar chart group, containing all the series plotted with the bar chart format.

使用Chart对象的**ChartGroups** 方法可返回ChartGroups集合。Use the ChartGroups method of the Chart object to return the ChartGroups collection.

以下示例显示工作表 1 上嵌入图表 1 中图表组的个数。The following example displays the number of chart groups on embedded chart 1 on worksheet 1.

MsgBox Worksheets(1).ChartObjects(1).Chart.ChartGroups.Count

使用ChartGroups (索引), 其中_索引_是图表组的索引号, 返回单个ChartGroup对象。Use ChartGroups (index), where index is the chart-group index number, to return a single ChartGroup object. 下面的示例向图表工作表 1 上的图表组 1 中添加垂直线。The following example adds drop lines to chart group 1 on chart sheet 1.

Charts(1).ChartGroups(1).HasDropLines = True

如果图表已被激活, 您可以使用ActiveChartIf the chart has been activated, you can use ActiveChart.

Charts(1).Activate 
ActiveChart.ChartGroups(1).HasDropLines = True

因为当特定图表组所用的图表格式更改时,该图表组的索引号可能会更改,所以使用命名图表组快捷方法之一来返回特定的图表组会更加容易。Because the index number for a particular chart group can change if the chart format used for that group is changed, it may be easier to use one of the named chart group shortcut methods to return a particular chart group. PieGroups 方法返回图表中的饼图组的集合, LineGroups 方法返回折线图图表组的集合, 依此类推。The PieGroups method returns the collection of pie chart groups in a chart, the LineGroups method returns the collection of line chart groups, and so on. 这些方法中的每一个都可以与索引号配合使用以返回单个 ChartGroup 对象,或不指定索引号而返回 ChartGroups 集合。Each of these methods can be used with an index number to return a single ChartGroup object, or without an index number to return a ChartGroups collection.

方法Methods

属性Properties

另请参阅See also

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.