1. Trang chủ >
  2. Công Nghệ Thông Tin >
  3. Quản trị mạng >

Figure 21-12. Axis units and scale

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (5.72 MB, 490 trang )


Figure 21-14. Illustrating ReversePlotOrder (after)



21.6.12 Type Property

The Type property returns or sets the axis type. It can be one of the following XlAxisType

constants:

Enum XlAxisType

xlCategory = 1

xlValue = 2

xlSeriesAxis = 3

End Enum



21.7 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.



373



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



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

chapter).

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)



374



Note, however, that there is no ColumnChartGroups collection per se. The ColumnGroups method

actually returns a ChartGroups collection, but not the full collection that would be returned by:



ChartObject.ChartGroups

To illustrate, the chart in Figure 21-15 has two series. While each series has a line type, the

subtypes are different. One series has been formatted with a line type with no data point markers,

whereas the other has data markers. Accordingly, the code:

ActiveChart.LineGroups.Count



returns the value 2, since there are two distinct ChartGroup objects that fit in the LineGroups

collection.

Figure 21-15. Illustrating chart groups



The Chart object has the following methods that return corresponding collections of ChartGroup

objects:



















AreaGroups

BarGroups

ColumnGroups

DoughnutGroups

LineGroups

PieGroups

RadarGroups

XYGroups



There are also some members of the Chart object that return chart groups for 3-D charts. They are:

Area3DGroup, Bar3DGroup, Column3DGroup, Line3DGroup, Pie3DGroup, and SurfaceGroup.

These members are singular because they return a single ChartGroup object.

The portion of the Excel object model that relates to ChartGroup objects is shown in Figure 21-16.

Figure 21-16. The ChartGroup object



375



21.8.1 UpBars and DownBars

UpBars and DownBars are shown in Figure 21-17. These bars give a quick indication of the

difference between data values in two different data series of line type. The UpBars are in white

and DownBars are in black. The code to generate these bars is:

With ActiveChart.LineGroups(1)

.HasUpDownBars = True

.UpBars.Interior.Color = RGB(255, 255, 255)

.DownBars.Interior.Color = RGB(0, 0, 0)

End With



Note that UpBars and DownBars apply only to 2-D line-type charts.

Figure 21-17. UpBars are in white and DownBars are in black



21.8.2 DropLines

DropLines are vertical lines that extend from the data markers on a line chart to the category axis.

The HasDropLines property of the ChartGroup object can be set to True to display DropLines.



376



21.8.3 HiLoLines

HiLoLines are shown in Figure 21-18. The HasHiLoLines property of the ChartGroup object can

be set to True to display HiLoLines. HiLoLines apply only to two-dimensional charts.

Figure 21-18. HiLoLines



AM

FL

Y



21.8.4 SeriesCollection and Series Objects



21.8.5 SeriesLines



TE



The SeriesCollection property of a ChartGroup object returns the SeriesCollection collection of all

Series objects that lie in that chart group. We will discuss Series objects later in the chapter.



SeriesLines are shown in Figure 21-19. They apply only to stacked column or stacked bar chart

groups. The HasSeriesLines property can be set to True to display series lines for a chart group.

Figure 21-19. SeriesLines



377 ®

Team-Fly



Xem Thêm
Tải bản đầy đủ (.pdf) (490 trang)

×