Microsoft Office Tutorials and References
In Depth Information
21.8 The ChartGroup Object
The ChartArea object has several children—Border, ChartFillFormat, Font, and Interior—that can
be used to set the characteristics of the entire chart. (These objects have been discussed earlier, in
connection with axis titles.)
Unfortunately, the documentation does not clearly define the differences between the
ChartFillFormat object (which represents fill formatting for chart elements) and its use and
between the Interior object and its use. Thus, some experimenting is in order. While both of these
objects have a Pattern property in common, they seem generally to have different properties and
methods. The ChartFillFormat object appears to relate more to gradient and texture fills, whereas
the Interior object seems to relate more to solid fills and pattern fills.
To illustrate, the following line sets the interior of a chart area to a solid color (ColorIndex 3 is
ActiveChart.ChartArea.Interior.ColorIndex = 3
The following code creates a gradient pattern in the chart area, changing from red at the top to
violet at the bottom:
With ActiveChart.ChartArea.Fill
.Visible = True
.ForeColor.SchemeColor = 3
.BackColor.SchemeColor = 7
.TwoColorGradient Style:=msoGradientHorizontal, Variant:=1
End With
21.8 The ChartGroup Object
As you no doubt know, an Excel chart can contain more than one data series. We have remarked
that each series (that is, the Series object) has a ChartType property that can be used to set the
chart type of the series. Thus, a single chart may have one or more series with a column-type
format and one or more series with a line-type format.
A ChartGroup object represents one or more series that are plotted on a chart with the same chart
type. Note that a ChartGroup object is not a collection. To access the individual Series objects
represented by a ChartGroup, we must use the SeriesCollection property (discussed later in this
The ChartGroup objects for a single chart are stored in the ChartGroups collection for the Chart
object. This collection is accessed using the ChartGroups property.
The Excel object model provides a way to get "subcollections" of the ChartGroups collection that
correspond to the major chart types (line, column, bar, etc.). To illustrate, the ColumnGroups
method applies to a 2-D chart and returns the collection of all ChartGroup objects that correspond
to the various column-type formats. The syntax is:
ChartObject .ColumnGroups
We can also access a single ChartGroup in this collection using the syntax:
ChartObject .ColumnGroups( Index )
Search JabSto ::

Custom Search