Fig 1: Simple Line Chart.
If not configured, the vertical axis defaults to six ticks with an increment of 20, ranging from 0 to 100: 0,20,40,60,80,100. To configure the vertical axis, use the following properties:
Fig 2: Simple Line Chart: vertical axis configured.
The data itself is labeled, using the xValueLabels property:
Fig 3: Simple Line Chart: vertical axis configured, data labeled.
Line charts can of course have multiple sets of data displayed. The numgroups property is used to define the number of data sets. The data for each set is listed in the data property: the first value applies to the first set, the second value to the second set, the third value to the third set and so on, looping through the data sets.
Fig 4: Simple Line Chart with multiple data sets.
Line Charts - Data Based
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Define variables to be used including a temporary table c_values = "" c_names = "" c_table = "_" + tmpnam() // Open the database and extract the data into the temporary table exec sql open database southwind; exec sql select count(orderid) orders, shipvia shipper, month(orderdate) month from orders where year(orderdate)=1997 group by 3,2 save as &c_table; |
Traverse the temporary table using the 4GL SCAN command to build up the comma-separated string c_values with the number of orders.
// Scan the table to build up the strings
use &c_table
scan
c_values = c_values + ltrim(str(orders))+","
endscan
|
The c_values variable can then be used as the line chart's data property.
Define the graph, macro-substituting the c_values variable (using the 4GL & macro operator).
// Define the graph
@02,05 to 13,75 properties "control=graphcontrol;;
id=chart1;;
type=line;;
data=&c_values;;
minvalue=0;;
maxvalue=20;;
yTicks=11;;
yTickinc=2;;
yValueLabels=0,2,4,6,8,10,12,14,16,18,20;;
xValueLabels=Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec;;
numgroups=3"
read
|
Define the legend with the Shipping Company names.
// Define the legend
@18,24 to 22,55
@19,28 say bold("<- Speedy Express") color b
@20,28 say bold("<- United Package") color r
@21,28 say bold("<- Federal Shipping") color g
|
Complete source:
// Define variables to be used including a temporary table c_values = "" c_names = "" c_table = "_" + tmpnam() // Open the database and extract the data into the temporary table exec sql open database southwind; exec sql select count(orderid) orders, shipvia shipper, month(orderdate) month from orders where year(orderdate)=1997 group by 3,2 save as &c_table; // Scan the table to build up the strings use &c_table scan c_values = c_values + ltrim(str(orders))+"," endscan // Define the graph @02,05 to 13,75 properties "control=graphcontrol;; id=chart1;; type=line;; data=&c_values;; minvalue=0;; maxvalue=20;; yTicks=11;; yTickinc=2;; yValueLabels=0,2,4,6,8,10,12,14,16,18,20;; xValueLabels=Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec;; numgroups=3" // Define the legend @18,24 to 22,55 @19,28 say bold("<- Speedy Express") color b @20,28 say bold("<- United Package") color r @21,28 say bold("<- Federal Shipping") color g read close databases |
Unlike the bar chart and pie chart graph controls, the line chart has no onDoubleClick event handler.
There is a whole range of further properties that can be used to configure the display of the Line Chart:
|
Property |
Example |
Description |
|
xtitle |
xtitle=No of Orders |
The vertical axis title. |
|
ytitle |
ytitle=Shipping Company |
The horizontal axis title. |
|
pixelyTitle |
pixelyTitle=20 |
The row position in pixels of the horizontal axis title. |
|
pixelxTitle |
pixelxTitle=500 |
The column position in pixels of the horizontal axis title. |
|
pixelWidthTitle |
pixelWidthTitle=200 |
The width of the horizontal axis title. |
|
borderColor |
borderColor=red |
The foreground color of the border. |
|
borderWidth |
borderWidth=3 |
The width of the border line. |
|
shadowStyle |
shadowStyle=raised |
The shadowing effect style: raised, recessed, etchedIn, etchedOut. The shadowing effect is only available if borderWidth is 0 or not specified. |
|
shadowWidth |
shadowWidth=3 |
The width in pixels of the shadowing effect. |
|
wallpaper |
wallpaper=+gradient_blue.gif |
The background, 'wallpaper' image. The image file name can be preceded by a '-' to tile the image to fit or by a '+' to stretch the image to fit. |
|
titleBackColor |
titleBackColor=blue |
The background color of the horizontal and vertical axes titles. |
|
titleForeColor |
titleForeColor=white |
The foreground color of the horizontal and vertical axes titles. |
|
labelForeColor |
labelForeColor=navy |
The foreground color of the data labels (xValueLabels) and tick labels (yValueLabels). |
|
colorData |
colorData=red,yellow,green |
The line colors. The default colors are: blue, red, green, yellow, aqua, pink, fuchsia, gray, orange, navy, white, coral, beige, paleturquoise, darkgray. These are repeated as required |
|
axisForeColor |
axisForeColor=navy |
The color of the vertical and horizontal axes. |
|
horiLineColor |
horiLineColor=gray |
The color of the horizontal gridlines. |
|
vertLineColor |
vertLineColor=silver |
The color of the vertical gridlines. |
Click image to display full size
Fig 6: Line Chart with additional display properties set.
@02,05 to 13,75 properties "control=graphcontrol;;
id=chart1;;
type=line;;
data=&c_values;;
minvalue=0;;
maxvalue=20;;
yTicks=11;;
yTickinc=2;;
yValueLabels=0,2,4,6,8,10,12,14,16,18,20;;
xValueLabels=Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec;;
numgroups=3"
// Use SHOW OBJECT TO avoid "String is too long" errors
show object "graphcontrol" properties "command=properties;id=chart1;;
xtitle=No of Orders;;
ytitle=Month;;
borderColor=navy;;
borderWidth=3;;
wallpaper=+gradient_blue.gif;;
titleBackColor=blue;;
titleForeColor=white;;
labelForeColor=navy;;
colorData=red,blue,green;;
axisForeColor=navy;;
horiLineColor=gray;;
vertLineColor=silver"
@18,24 to 22,55
@19,28 say bold("<- Speedy Express") color r
@20,28 say bold("<- United Package") color b
@21,28 say bold("<- Federal Shipping") color g
read
|
The following color names can be used by the Mirage .NET client.
|
Colors |
|||
|---|---|---|---|
|
aliceblue |
darkslategray |
lightseagreen |
papayawhip |