Using parameters, you can specify a data source for the Chart Viewer in order to display different data with a chart template or create a chart from scratch.
This is some sample HTML code that uses the Chart Viewer to view a chart drawn using data extracted from a database.
<applet code = "quadbase.chartviewer.Viewer.class" width=640 height=480> <PARAM name="sourceDB" value="jdbc:odbc:DataSource, sun.jdbc.odbc.JdbcOdbcDriver, username, password, select * from products"> <PARAM name="dataMap" value="0 1 -1 3"> <PARAM name="chartType" value="3D Column"> </applet>
The arguments of dataMap
specify how the chart utilizes different columns from the input data to plot the chart. In case of a scatter chart, they are series, x-value, y-value, and z-value. For a high low open close or high low chart the numbers are series, category, high, low, open, and close. For all other charts, the arguments are series, category, sumBy, and value. If you would like more information,please see the chapter on Column Mapping in the Chart API reference. The argument chartType
specifies the type of chart to be displayed and it can be one of:
2D Column
3D Column
2D bar
3D bar
2D stack bar
3D stack bar
2D stack column
3D stack column
2D area
3D area
2D stack area
3D stack area
2D line
3D line
2D pie
3D pie
2D scatter
3D scatter
2D High Low
3D High Low
2D HLCO
3D HLCO
2D 100% Column
3D 100% Column
3D Surface
2D Bubble
2D Overlay
2D Box
2D Radar
2D Dial
2D Gantt
2D Polar
This HTML code draws a chart using data from a data file:
<applet code = "quadbase.chartviewer.Viewer.class" width=640 height=480> <PARAM name="sourceFile" value="http://.../test.dat"> <PARAM name="dataMap" value="-1 0 -1 1"> <PARAM name="chartType" value="3D Pie"> </applet>
It is possible to have Chart Viewer read in data directly from the HTML file itself rather than from a data file or from a database.
<applet code = "quadbase.chartviewer.Viewer.class" width=640 height=480> <PARAM name="sourceData" value="int, string, int | value, name, vol | 10, 'John', 20 | 3, 'Mary', 30 | 8, 'Kevin', 3 | 9, 'James', 22"> <PARAM name="dataMap" value="-1 1 -1 2"> <PARAM name="chartType" value="3D Bar"> </applet>
The format for the parameter sourceData
is the same as the data file format, except that each line is ended by a vertical bar “|”.