| |
iGRAPH
The utility iGRAPH is driven by a single command, iweb/igraph, through which you generate
an IFS stream file containing the desired graph. A parameter of the command tells whether you want the graph be
immediately displayed from the iWEB Runtime Applet.
2.1 - Types of graphs
The following are some examples of the graphs that can be generated through command iweb/igraph.
Please note that the size of the generated graph depends on some parameters specified in the command.
|
|
| Figure 2-1 Sample pie graph |
- the pie can be rotated
- whenever the legend does not fit in the picture, you can move it through a ruler.
|
|
|
| Figure 2-2 Sample line graph |
|
|
|
| Figure 2-3 Sample vertical bar chart |
|
|
|
| Figure 2-4 Sample horizontal bar chart |
|
2.2 - Command iGraph
>>-IGRAPH--TYPE(--+-*BAR-+--)----------------------->
+-*PIE-+
-*LIN-
>--WIDTH(--chart-pixel-width--)--------------------->
>--HEIGTH(--chart-pixel-heigth--)------------------->
>--TITLE(--+-*NONE-------+)------------------------->
‘-chart-title-‘
>--VALUES(--1st-element-value---)-------------------->
[,2nd-element-value]
[,3rd-element-value]
[,nth-element-value]
… (1)
>--DECIMALS(--fixed-number-of-decimals--)----------->
>--LABELS(--1st-element-label---)-------------------->
[,2nd-element-label]
[,3rd-element-label]
[,nth-element-label]
… (1)
>--LEGEND(--1st-element-legend---)------------------->
[,2nd-element-legend]
[,3rd-element-legend]
[,nth-element-legend]
… (1)
>--BARALIGNME(--+-*VERTICAL---+--)------------------>
-*HORIZONTAL-
>--TOSTMF(--+-*NONE--------------------+)----------->
‘-to-stream-file-name.html-‘
>--RUN(--+-*YES-+--)-------------------------------->
-*NO-
|
|
| Figure 2-5 Structure of command iGraph |
|
(1) = Up to 1025 elements
Command parameters
- TYPE - Identifies the type of the graph.
Select one of the following:
- WIDTH - Identifies the width of the graph in pixel (px).
The default value is 850 px.
- HEIGHT - Identifies the height of the graph in pixel (px).
The default value is 450 px.
- TITLE - The title of the graph (256 char max). Must be within quotes.
Example: TITLE('Monthly Sales')
- VALUES - The most important parameter. This is a list of the values to be plotted by the graph.
- the list must be within quotes
- each value is separated from the next one by a comma (,)
- up to 5 decimal digits supported; a decimal point (.) must be used
- the total length of this string must not exceed 2,048 char
Example: VALUES('2.33,5.5,4.6')
- DECIMALS - Fixed number of decimals to be assigned to all the values.
Adjustments performed as needed. Default is 0.
- LABELS - This is a list of small labels to be assigned to each value in the VALUES list.
- the list must be within quotes
- there must be as many labels as values
- each label is separated from the next one by a comma (,)
- the total length of this string must not exceed 2,048 char
Labels are shown on one of the axes for the bar chart and for the line graph. For the pie graph, instead,
labels are shown my moving the mouse over the appropriate slices.
- LEGEND - This is a list of legends to be assigned to each value in the VALUES list.
- the list must be within quotes
- there must be as many legends as values
- each legend is separated from the next one by a comma (,)
- the total length of this string must not exceed 2,048 char
Legends are displayed aside from the graph.
- BARALIGNME - This parameter, though requested in all cases, is meaningful only for TYPE(*BAR).
Two values are allowed:
- *VERTICAL (default), for vertical bar charts, see Figure 2-3
- *HORIZONTAL, for horizontal bar charts, see Figure 2-4
- TOSTMF- Fully qualified name of the IFS stream file where the graph should be generated.
Extension .html is mandatory.
The user profile running the igraph command must have write authority over the specified IFS path.
You must also make sure that the target directory is allowed to the HTTP instance (e.g. the iWEB Runtime instance)
supposed to be used to display the graph.
If you specify *NONE for this parameter, you must also specify RUN(*YES).
In this case, just a temporary graph is created. Once displayed, it is gone.
- RUN - This parameter tells whether the graph should be immediately displayed by the iWEB Runtime Applet.
Select
- *YES, to have the graph immediately displayed bt the iWEB Runtime Applet
- *NO, to just save the graph as an IFS stream file. Such a graph could be shown at a later time,
see section Displaying a generated graph at the end of this chapter.
For an example of the iweb/igraph command used to generate the graphs in Figures 2.1 to 2.4,
see Figure 2.6.
IWEB/IGRAPH TYPE(*BAR)
WIDTH(500)
HEIGHT(265)
TITLE('Monthly Sales')
VALUES('100,102,135,143,132,157,145,26,131,158,212,237')
DECIMALS(0)
LABELS('Gen,Feb,Mar,Apr,May,Giu,Jul,Aug,Sep,Oct,Nov,Dec')
LEGEND('January,February,March,April,May,June,
July,August,September,October,November,December')
BARALIGNME(*HORIZONTAL)
TOSTMF('/iwebdir/dira/bar02.html')
RUN(*NO) |
|
| Figure 2-6 Sample iGraph command |
2.3 - Dynamic command generation
Usually the iweb/igraph command is generated and run from an RPG program. Typically such a program would
- scan some database file(s) and score some results in a table
- build the iweb/igraph command in a string (character) program variable
- run the iweb/igraph command by calling program qsys/qcmdexc and passing such a string variable.
D iGraphCmd s 2000
D cmdLen s 15p 5 inz(%len(iGraphCmd))
D Results s 10i 0 dim(12)
* Scan the database file(s) and score results in Results table
C exsr DBScan
* Build the iGraph command
C eval iGraphCmd='iweb/igraph +
C tostmf(''/iwebdir/dir01/pie01.html'') +
C run(*yes) +
C type(*pie) width(850) height(450) +
C title(''Monthly Sales'') +
C decimals(0) +
C labels(''Jan,Feb,Mar,Apr,May,Jun,+
C Jul,Aug,Sep,Oct,Nov,Dec'') +
C legend(''January,February,March,April,+
C May,June,July,August,September,+
C October,November,December'') +
C baralignme(*VERTICAL) values('''
C 1 do 12 i
C eval iGraphCmd=%trim(iGraphCmd) +
C %editc(Results(i):'1')
C if i>1 and i<12
C eval iGraphCmd=%trim(iGraphCmd) +','
C endif
C enddo
C eval iGraphCmd=%trim(iGraphCmd) +''')'
* Run the iGraph command
C call 'QSYS/QCMDEXC'
C parm iGraphCmd
C parm cmdLen
|
|
| Figure 2-7 Program generating the iGraph command |
2.4 - Displaying a generated graph through iWEB Runtime
To create a graph, command iweb/igraph must be executed. This is generally done through an RPG program
(see Figure 2-7).
The question is when and how such a program would be called.
One way could be that of generating the graph IFS stream file in advance, for instance through a daily batch job.
The graph could then be displayed through one of the following techniques implemented via
iWEBMaster language:
- Creating a "link" to be connected to some display file record format(s); example:
IWEB/CRTOBJDFN OBJ(...) OBJTYPE(LINK) HREF('/iwebdir/dir01/pie01.html') ...
In this case the graph is displayed along with the 5250 screen page.
- Creating a "button" to appear on some some display file record format(s); example:
IWEB/CRTOBJDFN OBJ(...) OBJTYPE(BUTTON) BUTTONACT(LINK) HREF('/iwebdir/dir01/pie01.html target=_blank') ...
In this case the graph is displayed in a new window when the user presses the button.
If, instead, the graph should be temporarily generated and displayed at the time the user presses a button,
the technique would be that of assigning the display file record format a
iWEBMaster language button
invoking the graph generating program. Example:
IWEB/CRTOBJDFN OBJ(...) OBJTYPE(BUTTON) BUTTONACT(SYSCMD) SYSCMD('''call mylib/mypgm''')
| |