docs.roxen.comBack to normal mode
DocsRoxen2.2TutorialsDatabase Tutorial
Copyright © 2004, Roxen Internet Software
Suggestions, comments & compliments
manuals@roxen.com

The Business Graphics Module

The business graphics module (providing the diagram tag) allows Roxen to build different kind of diagrams on-the-fly. A reference chapter on the module's features (ref: the business graphics module chapter) is available.

We won't duplicate the reference specification, but instead focus on how to use a sql data-source to feed a diagram generation tag.

We'll start off with an example:

Show a graphic documenting the total areas for the known countries:


<diagram type=barchart horgrid name="Areas" 
  namefont="franklin gothic demi" namesize=25>
<data xnames form=column xnamesvert>
<sqltable ascii host="mysql://user:password@localhost/sample"
           query="select name,area_land,area_tot from ids, countries where
                  ids.code=countries.country order by area_tot desc">
</data>
<legend separator=|>Total area|Land area</legend>
</diagram>

In the example, the data are fed by columns rather than by rows (which is the default for the diagram tag) because SQL modules are better suited for that kind of layout.

The <sqltable> tag, together with the ascii parameter, is the most suited system to feed data to a <diagram> tag.

You always need to watch out for possible field separator misinterpretation problems: the default field separator (the tab character) and line separator (newline) are not usually found in SQL-obtained data-sources, especially the numeric data used to feed the diagram module. But you must not take this for granted, so make sure to check, and possibly use a different separator and the <sqloutput> tag to make sure.