The ChartArea Object

The ChartArea object represents the chart area of a chart. As shown in Figure 21-1, the chart area on a 2-D chart contains essentially the entire chart: the axes, chart title, axis titles, and legend. On the other hand, the chart area on a 3-D chart contains the chart title and the legend but does not include the plot area, where the data is plotted.

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 red):

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