Modifying graph properties

When you define a graph in the Window or User Object painter, you specify its behavior and appearance. For example, you might define a graph as a column graph with a certain title, divide its Value axis into four major divisions, and so on. Each of these entries corresponds to a property of a graph. For example, all graphs have an enumerated attribute GraphType, which specifies the type of graph.

When dynamically changing the graph type

If you change the graph type, be sure to change other properties as needed to define the new graph properly.

You can change these graph properties at runtime by assigning values to the graph's properties in scripts. For example, to change the type of the graph gr_emp to Column, you could code:

gr_emp.GraphType = ColGraph!

To change the title of the graph at runtime, you could code:

gr_emp.Title = "New title"

How parts of a graph are represented

Graphs consist of parts: a title, a legend, and axes. Each of these parts has a set of display properties. These display properties are themselves stored as properties in a subobject (structure) of Graph called grDispAttr.

For example, graphs have a Title property, which specifies the title's text. Graphs also have a property TitleDispAttr, of type grDispAttr, which itself contains properties that specify all the characteristics of the title text, such as the font, size, whether the text is italicized, and so on.

Similarly, graphs have axes, each of which also has a set of properties. These properties are stored in a subobject (structure) of Graph called grAxis. For example, graphs have a property Values of type grAxis, which contains properties that specify the Value axis's properties, such as whether to use autoscaling of values, the number of major and minor divisions, the axis label, and so on.

Here is a representation of the properties of a graph:

Graph
      int Height
      int Depth
      grGraphType GraphType
      boolean Border
      string Title
      
grDispAttr TitleDispAttr, LegendDispAttr, PieDispAttr
      string FaceName
      int TextSize
      boolean Italic
      
grAxis Values, Category, Series
      boolean AutoScale
      int MajorDivisions
      int MinorDivisions
      string Label

Referencing parts of a graph

You use dot notation to reference these display properties. For example, one of the properties of a graph's title is whether the text is italicized or not. That information is stored in the boolean Italic property in the TitleDispAttr property of the graph.

For example, to italicize title of graph gr_emp, code:

gr_emp.TitleDispAttr.Italic = TRUE

Similarly, to turn on autoscaling of a graph's Values axis, code:

gr_emp.Values.Autoscale = TRUE

To change the label text for the Values axis, code:

gr_emp.Values.Label = "New label"

To change the alignment of the label text in the Values axis, code:

gr_emp.Values.LabelDispAttr.Alignment = Left!

For a complete list of graph properties, see Objects and Controls or use the Browser.

For more about the Browser, see the section called “Browsing the class hierarchy” in Users Guide.