The following ESL program is an example of how to use the Business Graphics module to create a 3-D bar graph.
module BGraph # Invokes BGraph module.
integer variable Set # Holds current data set
# while loading GDataY.
string variable CurrentGraphPart # Holds selected object.
primary graphical region Primary_GR
size 400 300 at 30 30
in desktop
invisible textual region DataArea
# Place where data will
# be extracted from and
# placed in GDataY.
size 40 40 at 10 10
in Primary_GR
font "medium"
insert "Hardware 24 29 15 27\n"
insert "Software 34 45 53 61\n"
insert "Maintenance 18 33 22 42"
invisible blue graphical region GraphArea
# Region that will
# contain the finished
# graph.
size 380 200 at 10 80
in Primary_GR
white border
blue graphical region MakeGraph
# A key to create
# the graph.
size 80 22 at 30 30
in Primary_GR
white border
text " Graph"
red graphical region Quit
# A key to stop
# the program.
size 80 22 at 290 30
in Primary_GR
white border
text " Exit"
invisible sense region SelectArea
# Region to hold moved
# GMovables parts of
# the graph.
size 300 300 at 100 50
in Primary_GR
priority is 12
# The following action routine reads the table of numbers from
# DataArea and loads it into the array GDataY. Once GDataY
# contains the data, the module uses it to create the graph.
action ExtractGraphData is
copy 1 to Set
while (Set <= bottom of DataArea) loop
extract from textual line Set from DataArea
take word GLegend[Set] # Title of data set (legend)
take word GDataY[Set,1]
take word GDataY[Set,2] # There are 4 data elements
take word GDataY[Set,3] # in this example.
take word GDataY[Set,4]
copy (Set+1) to Set
end loop
copy (Set-1) to GDataSets # Calculated number of data
# sets.
response to start
copy 4 to GDataElements # Tell the module the number of
# data elements.
copy "GraphArea" to GRegion # Tell the module where to
# display the graph.
copy "BGraph Example" to GTitle # Give the graph a main title,
copy "medium" to GTitleFont # and display it in "large"
# font.
copy "'88" to GLabels[1] # Label the data elements
copy "'89" to GLabels[2] # along the X axis.
copy "'90" to GLabels[3]
copy "'91" to GLabels[4]
copy true to Graph3D # The bar graph will be
# 3-D.
action ExtractGraphData # Load the data into GDataY.
response to MakeGraph
action GBars # Tell the module to create
make GraphArea visible # a bar graph.
response to GMovables
copy object in GraphArea to CurrentGraphPart
make SelectArea visible
enable SelectArea
begin resumable
response to SelectArea
change CurrentGraphPart position to xcoord ycoord
make SelectArea invisible
disable SelectArea
leave block
end
response to Quit
exit