| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (5 out of 7)

Using Chart Annotations

After creating a chart and determining its style, you can optionally format the chart using annotations.

Charts are composed of several components:

Each component consists of formatting attributes that define the chart's appearance. For example, the axis component includes the axis-minimum, axis-maximum, and axis-crossover attributes. Formatting attributes are a special kind of attribute used only in formatting freeform tables and charts. Annotations are statements that describe the value of one or more formatting attributes of a chart component.


Note: When referring to component attributes, this chapter uses the term attribute somewhat loosely. Unlike most other item attributes, a chart's component attributes are not accessible as individual attribute names on attribute tables. Instead, you provide values for these attributes through annotation statements.

Unlike trend chart components, which are organized into component subtables, chart components are accessible only as annotations. Syntactically, chart annotations are almost identical to those found on trend charts. They differ, however, in their organizational and descriptive statements.

Trend chart annotations explicitly state the components to which they refer. They begin with a component statement, followed by one or more component attributes and values, such as:

indicating that there is one value axis, and that its label-color attribute has a value of red.

In contrast, chart annotations do not explicitly state the component to which they refer. The attribute name indicates the relevant component, as these annotations do:

In this example, grid-color is a chart component attribute, and indicator is an attribute of the chart's data point component.

While you can enter chart annotations in any order, G2 may regroup certain attributes so that they appear together for one component.

Default Chart Annotations

Each chart style that G2 provides includes a set of default values for each of the components. Though you cannot see the default values as annotations in the chart's attribute table, the defaults exist as part of that item's knowledge. The component attribute defaults for each chart style are shown next. The notation N/A indicates that the default is not applicable.

Chart Style
Component Attribute Line-chart Scatter-chart Column-chart
All
line-color
black
black
black
Axis axis-minimum (1)



axis-maximum (1)



axis-crossover
zero
zero
zero
number-of-tickmarks



tickmark-interval



Chart background-color
transparent
transparent
transparent
border-color
black
black
black
grid-color
black
black
black
grid-visible
false
false
false
Data-series connection-line-visible
true
false
false
line-from-last-to-first-point-visible
false
false
true
Data-point height
5
5
N/A
indicator
square
square
bar
indicator-visible
false
true
true
width
5
5
5

Shaded component attributes without values are those that have an unspecified default. For these attributes, G2 calculates an appropriate value based upon the data that the chart is plotting.

Axis Component Attributes

Here are the axis component attributes.

Specifying the Minimum and Maximum Axis Values

The Axis-minimum and the Axis-maximum attributes specify a number on the axis that shows the beginning and end of the range of data. Axis 1 is the horizontal axis and axis 2 is the vertical axis. An example is:

Specifying Where Axes Cross

The Axis-crossover attribute specifies a point on the axis where the other axis crosses it. The point is an integer, whose default value is zero. If zero is not on the axis, the default is the axis-minimum. If you specify an axis-crossover value that is outside the axis range, G2 overrides it and uses the axis-minimum value. An example is:

Specifying the Number of Tickmarks on an Axis

The Number-of-tickmarks attribute specifies the number of tickmarks on the axis. An example is:

Specifying the Tickmarks Interval

The Tickmarks-interval attribute specifies the distance between successive tickmarks on an axis. An example is:

Chart Component Attributes

These are the chart component attributes.

Setting a Chart's Background Color

The Background-color attribute determines the background color of the entire chart. Unlike trend charts, there is no way to separate the background color of the actual data window, in which the data series values display, from the outer edge of that area. The default background color is transparent.

Setting a Chart's Border Color

The Border-color annotation determines the chart's external border color. There is no annotation to set the border that bounds the data window area, in which the data series values appear. The default is black.

Setting a Chart's Grid Color

The Grid-color attribute specifies the color of the grid for either axis. Conceptually, a grid is an extension of an axis tickmark to the full size of the chart. You can specify a grid-color for both axes, or for either axis individually. Some examples are:

Specifying Whether Grid Lines are Visible

The Grid-visible attribute turns grid lines on or off (true and false, respectively) for either or both axes. Some examples are:

Data Point Component Attributes

These are the attributes that compose the data point component.

Specifying the Height and Width of Data Points

The height and width attributes specify the height and width of a data point in pixels. Enter this attribute as an integer value. The height and width attributes are not applicable to line charts. The default value varies depending on the indicator you use. To change the default, enter an annotation like this:

The following diagram shows the effect of changing the data-point height and width from the default value to 10:


Defining a Chart's Indicator Type

The Indicator attribute defines what G2 displays at each data point in a data series. The next table lists the possible values for this attribute and the chart style they are appropriate for.

Indicator value Column chart style Scatter chart style
Square


Rectangle


Triangle


Cross


X


Bar


Column


Solid-bar


Solid-column



Hint: Adding an indicator annotation to a line-chart effectively changes the chart style to a column- or scatter-chart, depending on the value you specify.

Here are examples of an indicator of bar and solid-bar.


The next diagram shows a column chart with solid-column data-point indicators for two data series. The chart appears with upper and lower values since the list element values it represents are in opposite numeric ranges (random 10 to 20, and random -20 to -10).


Here are examples of each of the indicator attribute values appropriate for scatter charts:


As the previous table notes, indicator attribute values are appropriate for scatter or column chart types. The term appropriate, however, does not indicate that each value is exclusive to a chart type. On the contrary, changing the indicator attribute on a scatter or column chart effectively changes the chart style.

Consider the following column charts. The left-hand chart is one without a specific indicator attribute (the default is bar). The right-hand chart shows the effect of adding the annotation:

Such an annotation essentially changes the appearance of the column chart into a scatter chart:


You can specify a separate indicator for each data series on the chart, but only one indicator can be in effect at a time. If a chart includes one indicator annotation and you add another, closing the edit on the change causes G2 to delete the first annotation and keep the last change.

Two examples of indicator attribute annotations are:

Specifying Whether the Indicator is Visible

The Indicator-visible attribute specifies whether the indicator is visible. By default, an indicator is visible (true). Changing the Indicator-visible attribute to false effectively hides the data-series display. For example:

Data Series Component Attributes

Here are the attributes that comprise the data series component.

Specifying Whether Data Points are Connected

The Connection-line-visible attribute specifies whether there is a line between data-points in a data series. You can set this attribute to true or false. The Connection-line-visible attribute is not applicable to column charts.

An example of this annotation is:

For a line chart, this attribute is true by default. Changing it to false effectively hides all data points.

The next diagram shows the effect of changing the Connection-line-visible attribute to true upon a scatter chart.


Controlling Connecting Lines

The Line-from-last-first-point-visible attribute controls the appearance of a single connecting line from the last point in the data series to the first point. Use this when plotting data that samples one cycle of a cyclic process. Set this attribute to true or false. An example is:

Defining the Line Colors

The Line-color attribute is applicable to several components, including the chart's axis, data point and data series components.

You can specify the line color for a chart component attribute as a color or a meta-color as follows:

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (5 out of 7)

Copyright © 1997 Gensym Corporation, Inc.