What is a GLG
graph?
Like any other GLG
widget, a GLG graph is a GLG drawing representing a bar, line or
some other graph. The objects in the drawing are wired up using the GLG
dynamics, history and constraints mechanism to behave like a scrolling
graph when filled with data. The resources defined in the drawing are
used by an application at run-time to
configure the graph and supply graph data.
The drawings of all GLG graphs are constructed
using similar elements to represent graph
components such as axes, ticks, labels and data. A typical graph has a
data area, axes, grids, titles, minor and major ticks, major tick
labels for each axis, a data group containing graph data samples and
other elements as shown in the picture below. Click on the picture to see a bigger
image.

What
are common resources of a GLG graph?
All GLG graphs have similar resource hierarchies, which
slightly differ depending on the graph type.
The following lists resources of a bar graph. Most of these resources
are present in all graphs regardless of their type:
- DataGroup/Factor
- defines the number of datasamples in the graph
- DataGroup/DataSample/Low
- defines the low range of data
- DataGroup/DataSample/High
- defines the high range of data
- DataGroup/DataSample/Value
- defines an initial value for graph's samples
- DataGroup/ScrollType
- defines the graph's scroll type (WRAPPED or SCROLLED)
- DataGroup/EntryPoint
- an entry point for pushing data values into the graph.
- XLabelGroup/Factor
- defines the number of X labels, major ticks and grids
- XLabelGroup/MinorFactor
- defines the number of minor ticks per each major tick interval
- XLabelGroup/XLabel/String
- defines an initial value for the label, usually set to an empty string
- XLabelGroup/EntryPoint
- an entry point for pushing X axis labels into the graph
- YLabelGroup/Factor
- defines the number of Y labels, major ticks and grids
- YLabelGroup/MinorFactor
- defines the number of minor ticks per each major tick interval
- YLabelGroup/Low
- defines the low range of the Y axis labels, same as DataGroup/DataSample/Low
- YLabelGroup/High
- defines the low range of the Y axis labels, same as DataGroup/DataSample/High
A line graph has a slightly different resource
hierarchy for its DataGroup:
- DataGroup/Factor
- defines the number of datasamples in the graph
- DataGroup/Marker/DataSample/Low
- defines the low range of data
- DataGroup/Marker/DataSample/High
- defines the high range of data
- DataGroup/Marker/DataSample/Value
-defines an initial value for graph's samples
- DataGroup/ScrollType
- defines the graph's scroll type
- DataGroup/EntryPoint
- an entry point for pushing data values into the graph
A multi-line graph has a different DataGroup hierarchy as well:
- DataGroupOne/Factor
- defines the number of lines in the graph
- DataGroupOne/DataGroup/Factor
- defines a number of point in each line
- DataGroupOne/DataGroup/Marker/DataSample/Low
- defines the low range
- DataGroupOne/DataGroup/Marker/DataSample/High
- defines the high range
- DataGroupOne/DataGroup/Marker/DataSample/Value
- defines an initial value
- DataGroupOne/DataGroup/ScrollType
- defines the graph's scroll type
- DataGroupOne/EntryPoint
- an entry point for pushing data values into all lines
- DataGroupOne/DataGroupN/EntryPoint
- an entry point for pushing values into the N-th line
The top level
DataGroupOne/EntryPoint
resource of a multi-line graph may be used to push values into all
lines of the graph. The entry points of each line (the
DataGroupOne/DataGroupN/EntryPoint
resources, where N is the
index of a
line) may be used to push datasamples into each line separately.
You can use the Resource Browser to interactively browse a
graph's resources.
Refer to the GLG Widgets Reference Manual
for more information on graph's resources and their usage.
How do
I modify graph's resources and geometry?
Any graph widget may be loaded in the GLG Graphics Builder
and edited as described in the How
do I modify a widget section of the FAQ.
The Resource Browser may be used to browse and modify a graph's
resources. Elements of a graph may be also be edited directly to
position graph's titles, change geometry of the graph's DataArea or add
custom annotations.
How do I
prototype the graph
in the Graphics Builder?
The Run mode of the GLG Graphics Builder may be used to
prototype graphs run-time behavior using either simulated or real data
as described in the How do I
animate a widget section of the FAQ.
The graph widgets provide default run commands for animating them, and
can be animated by clicking on the Start
toolbar button and accepting the default
run command. Click on the Stop
button to stop prototyping.
The following is a sample of a default run command for a bar graph:
$datagen
-sleep 0.1
d 0 1
$Widget/DataGroup/EntryPoint
-period
1000 -incr s 0 1000 $Widget/XLabelGroup/EntryPoint
It uses the Builder's data generator to animate the $Widget/DataGroup/EntryPoint
resource of the double (d)
type with random data in the range from 0 to 1. It also supplies label
strings (s type) into the $Widget/XLabelGroup/EntryPoint, converting incremental label numbers to strings. The "-period 1000 -incr s 0 1000"
option informs the data generator to make 1000 iterations, starting
from 0 and ending at 1000, before going back to 0. The -sleep 0.1 option slows down the
refresh rate to about 10 updates per second.
Can I use the Graphics
Builder to generate a printout of a graph with real data?
Yes you can. The -script
option of the Graphics Builder's run command may be used to supply the
data from a script. For example, the following run command may be used
with a packed bar graph to generate a Nitrogen Lab Graph displayed
below:
$datagen -script nitrogen_lab_graph_data
The nitrogen_lab_graph_data file
contains a script that fills the graph with data and sets its titles
and labels. Click here to see
the content of the script file.

If there is a large number of graph values, they may be provided in a
separate file. For example, the following two command may be used to
configure the graph using the nitrogen_lab_graph_data2
script and then fill it with data from
the nitrogen_lab_graph_values
file:
$datagen -script nitrogen_lab_graph_data2
$datagen -datafile nitrogen_lab_graph_values d 0 1
$Widget/DataGroup/EntryPoint
The nitrogen_lab_graph_data2
script used by the first command to configure the graph is the same as nitrogen_lab_graph_data,
but without the values for the graph's
datasamples, which will be supplied by a separate file.
The second command uses the nitrogen_lab_graph_values
file that supplies values for the graph's datasamples.
Click here to see the content of
the data file.
When finished, the image of the graph may be saved using the File, Save Image option of the main
menu, or printed using the File,
Print option.
To save or print only the content of the graph, move the focus inside
the graph by clicking on the Set
Focus
button on the lower left of the drawing
area, then click on the graph to move the focus into it. Select Options, Draw Grid, No grid from
the main menu to disable the grid, then use Options, Show Axis to toggle the
axis display off if necessary. After saving or printing, unset the
focus by clicking on the Main Focus
button.
How do I use a graph widget in my application?
A graph widget is deployed in an
application using one of the programming containers provided in the GLG
libraries, as
described in the How
do
I use a widget in my application section of the FAQ.
How
do I change the number of data samples displayed in the graph?
For single-series graphs, such as a bar or line graphs,
the DataGroup/Factor resource
defines the number of the graph's datasamples.
For multi-series graphs, such as a multi-line graph, the DataGroupOne/DataGroup/Factor
resource defines the initial number of datasamples in each line.
The number of datasamples in each of the graph's line may also be
changed individually, by setting the DataGroupOne/DataGroupN/Factor resource
of each line after the hierarchy setup.
You can use the Resource Browser to
interactively browse the
graph's resources.
How
do I change the number of labels and minor ticks?
The number of labels and ticks on the X axis may be
changed using the following resources:
- XLabelGroup/Factor
- defines the number of X labels, major ticks and grids
- XLabelGroup/MinorFactor
- defines the number of minor ticks per each major tick interval
For the Y grid:
- YLabelGroup/Factor
- defines the number of Y labels, major ticks and grids
- YLabelGroup/MinorFactor
- defines the number of minor ticks per each major tick interval
You can use the Resource Browser to interactively browse the
graph's resources.
How
do I set the range of the graph?
For single-series bar graphs, the following resources
define the graph's range:
- DataGroup/DataSample/Low
- defines the low range of data
- DataGroup/DataSample/High
- defines the high range of data
For single-series line graphs, the resource are
slightly different:
- DataGroup/Marker/DataSample/Low
- defines the low range of data
- DataGroup/Marker/DataSample/High
- defines the high range of data
For multi-line graphs, the resources are:
- DataGroupOne/DataGroup/Marker/DataSample/Low
- defines the low range
- DataGroupOne/DataGroup/Marker/DataSample/High
- defines the high range
You can use the Resource Browser to interactively browse the
graph's resources.
How
do I set the initial value for the graphs samples?
The Value
resource of the DataSample
template defines the initial value of the graph's datasamples before
the data are filled in. The following resources may be used to set it
depending on the graph type:
- DataGroup/DataSample/Value
- for single-series bar graphs
- DataGroup/Marker/DataSample/Value
- for single-series line graphs
- DataGroupOne/DataGroup/Marker/DataSample/Value
- for multi-line graphs
The resource must be set before the hierarchy setup at
run time, or set in the graph's drawing.
You can use the Resource Browser to interactively browse the
graph's resources.
How do I set the
initial value for the graph's scrolling time labels?
The initial value of the scrolling labels is set using the
label's String resource. For
graphs that scroll horizontally along the X axis, the XLabelGroup/XLabel/String resource
may be used.
The resource must be set before the hierarchy setup at run time, or set
in the graph's drawing.
How
do I supply data to a graph?
A graph provides entry points for supplying scrolling
graph data and labels. For example, in a single-series graph such as a
bar or line graph, the following resources may be used to supply data and scrolling time labels to the graph:
DataGroup/EntryPoint
- graph data entry point
XLabelGroup/EntryPoint - label entry point
For multi-line graphs, the DataGroupOne/EntryPoint may be used
to supply data to all lines of the graph at once. Individual entry
points, such as DataGroupOne/DataGroupN/EntryPoint,
where N is a line index, may be used to supply data to each line
separately.
How do
I supply custom labels?
Custom labels for the scrolling time axis are supplied
though the XLabelGroup/XLabel/EntryPoint resource for graphs with the
horizontal time axis, as described in the previous section.
The labels for the value axis are generated automatically based on the
range of the graph. The number of digits after the decimal point may be
specified using the label's Format
resource, which defines a C-style format. To overwrite automatic
labeling and supply custom values, the Format resource may be set to a
string which does not contain the "%" format symbol.
For example, the format string "%.0lf" will display automatic labels
with no digits after the decimal point. Setting the YLabelGroup/YLabel0/Format resource
to the "3.75" string will cause the string to be displayed in the first
Y label. The Global flag of
the YLabelGroup/YLabel/Format
resource must be set to LOCAL in the drawing to set the Format resource of each label to a
different value.
Refer to the GLG Widgets Reference Manual
for more information.
How
do I add custom annotations to the graph?
Since the graph widget is a GLG drawing, you can add
new objects to it as described in the Can
I add new objects inside a widget or delete the ones I do not need
section of the FAQ.
Text objects may be added to annotate the graph or its axis. A label
may be added to each of the graph's datasamples by adding a text object
to the datasample's template to display the sample's value.
How
do I change the size of the graph's Data Area?
The size and position of the DataArea or any other
element of the graph may be changed by editing it using the mouse as
described in the Can I edit
objects in the widget's drawing directly section of the FAQ.
After traversing the hierarchy down into
the graph widget, click on the DataArea to select it and adjust its
size and position by dragging the DataArea or its control points with
the mouse.
When selecting the DataArea, notice the its name appearing in the
selected Name: indicator at
the bottom of the Builder's drawing area. Since the graph contains many
objects on top of the DataArea, the mouse click may select one of this
object instead of the DataArea.
If you have problems selecting the DataArea,
press and hold the Shift key
while clicking on it. This will bring the Object Selection dialog if
several objects are potentially selected by the click, so that you can
scroll through all selected objects to select the DataArea. If the Object Properties
dialog is active, the arrows to scroll through all selections will
become active in the upper left corner of the Object Properties dialog,
instead of activating the Object Selection dialog.
How
do I change the number of lines in a multi-line graph?
The number of lines is controlled by the graph's DataGroupOne/Factor resource.
How do I
assign line and marker colors in a multi-line graph?
The DataGroupOne/DataGroup/Polygon
resource is a line template, and it has Color0, Color1, ... resources that define
the color of each line. To change a color, select the color resource in
the Resource
Browser, then select a new color from a color palette.
The DataGroupOne/DataGroup/Marker
resource defines a template for line markers. It also has Color0, Color1, ... resources that define
the marker color for each line, which may be changed using the Resource
Browser.
I
have 10 lines, but I can see only 7 line color attributes in a
multi-line graph. How do I add more color attributes to the list?
The line colors are defined in a color list
transformation attached to the EdgeColor of the line polygon object. By
default, the color list contains seven colors. The number of colors in
the list may be increased by editing the color list transformation.
To increase the number of line colors:
- Select the graph's $Widget viewport and click on the Hierarchy
Down
button to traverse the hierarchy down
into it.
- Select the line series named DataGroupOne (a line with markers)
at the bottom of the DataArea,
and traverse the hierarchy
down into it.
- You'll see the DataGroup
object, which is a polyline object with markers used as a line
template. Click on the polyline to select it.
- Click on the Properties
toolbar button to display
its Properties dialog.
- Click on the Ellipsis
button next to the Polygon attribute and notice the "X" mark on the left of the EdgeColor attribute that indicates
it has a transformation attached to it.
- Click on the Ellipsis
button next to the EdgeColor to display the Attribute
Object dialog for the edge color, then click on the Dynamics: Edit button to edit the
color list transformation attached to it.
- Click on the List
of Values button to display the list of colors. Select the last
color in the list, then click on the Add
button several times to add a required number of colors.
- Select each of the added color entries,
name it ColorN, where N is a sequential item index: Color8, Color9, and so on. Set the Global
flag of each color entry to GLOBAL.
- Save the modified graph.
The marker colors are defined by a color list
transformation attached to the FillColor
attribute of the marker template. To increase the number of marker
colors, follow the following steps:
- Perform the steps 1-3 listed above to select the DataGroup object used as a line
template.
- Click on the Hierarchy
Down
button to traverse the hierarchy down
into the DataGroup.
- Click on the marker template (marker object) to
select it, then click on the Properties
toolbar button to display
the marker's Properties dialog. Notice the "X" mark on the left of the FillColor attribute which indicates
it has a transformation attached to it.
- Click on the Ellipsis
button next to the FillColor to display the Attribute
Object dialog for the fill color, then click on the Dynamics: Edit button to edit the
color list transformation attached to it.
- Perform the steps 7-9 listed above to add colors
to the color list transformation.