The following instructions explain how to use the BGraph module to create a graph.
Note that the predefined variables and action routines must be specified exactly as shown in boldface type.
1. Reference the BGraph module by inserting the following line at the top of your program:
module BGraph
All the variables and action routines are now available for use within the program.
2. Create a graphical region for the graph to be drawn in; for example:
graphical region SalesGraph size 300 300
at position 100 50 blue border
3. Copy the name of the region into the string variable GRegion; for example:
copy "SalesGraph" to GRegion
4. Copy the data elements for the graph into the GDataY string array. For example, if the input data came from the following table, we could divide it into data elements and data sets as follows:
SALES VOLUME (in thousands)
'88 '89 '90 '91
Product A 24 29 15 27
Product B 34 45.5 53 61
Product C 18 33 22 42
The data elements (24, 29, 15, 27, etc.) are grouped by data sets (Product A, Product B, and Product C). You reference a data element by specifying the data set and then the associated data element; for example:
copy "24" to GDataY[1,1] # This is the first data
# point in data set 1.
copy "29" to GDataY[1,2]
copy "15" to GDataY[1,3]
copy "27" to GDataY[1,4]
copy "34" to GDataY[2,1]
copy "45.5" to GDataY[2,2]
copy "53" to GDataY[2,3]
copy "61" to GDataY[2,4]
copy "18" to GDataY[3,1]
copy "33" to GDataY[3,2]
copy "22" to GDataY[3,3]
copy "42" to GDataY[3,4] # This is the fourth data
# point in data set 3.
5. Copy the number of data sets and elements per data set in the current graph to the variables GDataSets and GDataElements, respectively. For example, use the sample input data from step 4:
copy 3 to GDataSets
copy 4 to GDataElements
If the number of data sets is greater than 10, you must change the value of the constant GMaxDataSets. If the number of data elements per data set is greater than 20, you must change the value of the constant GMaxDataElements. (These constants are described later in this section. Set them as low as possible to avoid allocating unnecessary memory.)
6. If you choose to set optional variables for the graph, such as titles and fonts, legends, colors, and grid lines, refer to Customizing a Graph for descriptions of how to set these options before continuing.
7. Specify the action statement for the type of graph. For certain graph types, you must also set required variables. Find the specific type of graph you want to create in Table A-1, and follow the procedures specific to that graph type.
8. If you want other objects in GRegion, you must add them to the region after the graph is drawn. You must do this last because when a graph is created, the region specified by the variable GRegion is cleared, and any children of this region are deleted.