Using graphs
In PowerBuilder, there are two ways to display graphs:
- In a DataWindow, using data retrieved from the DataWindow
data source - In a graph control in a window or user object, using
data supplied by your application code
This chapter discusses the graph control and describes how
your application code can supply data for the graph and manipulate
its appearance.
For information about graphs in DataWindows, see the DataWindow Programmer’s
Guide
and the DataWindow Reference
.
To learn about designing graphs and setting
graph properties in the painters, see the PowerBuilder User’s
Guide
.
Working with graphcontrols in code
Graph controls in a window can be enabled or disabled, visible
or invisible, and can be used in drag and drop. You can also write
code that uses events of graph controls and additional graph functions.
Properties of graph controls
You can access (and optionally modify) a graph by addressing
its properties in code at execution time. There are two kinds of
graph properties:
- Properties
of the graph definition itself These properties are initially set in the painter when you
create a graph. They include a graph’s type, title, axis
labels, whether axes have major divisions, and so on. - Properties of the data These properties are relevant only at execution time, when
data has been loaded into the graph. They include the number of
series in a graph (series are created at execution time), colors
of bars or columns for a series, whether the series is an overlay,
text that identifies the categories (categories are created at execution
time), and so on.
Events of graph controls
Graph controls have the following events:
Clicked | DragLeave |
Constructor | DragWithin |
Destructor | GetFocus |
DoubleClicked | LoseFocus |
DragDrop | Other |
DragEnter | RButtonDown |
So, for example, you can write a script that is invoked when
a user clicks a graph or drags an object on a graph (as long as
the graph is enabled).
Functions for graph controls
You use the following PowerScript graph functions to manipulate
data in a graph.
Function | Action |
---|---|
AddCategory | Adds a category |
AddData | Adds a data point |
AddSeries | Adds a series |
DeleteCategory | Deletes a category |
DeleteData | Deletes a data point |
DeleteSeries | Deletes a series |
ImportClipboard | Copies data from the clipboard to a graph |
ImportFile | Copies the data in a text file to a graph |
ImportString | Copies the contents of a string to a graph |
InsertCategory | Inserts a category before another category |
InsertData | Inserts a data point before another data point in a series |
InsertSeries | Inserts a series before another series |
ModifyData | Changes the value of a data point |
Reset | Reset the graph’s data |