KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > charts > SalesChart


1 package charts;
2
3 import dinamica.*;
4
5 /**
6  * Demo Charting Transaction
7  **/

8 public class SalesChart extends GenericTransaction
9 {
10
11     /* (non-Javadoc)
12      * @see dinamica.GenericTransaction#service(dinamica.Recordset)
13      */

14     public int service(Recordset inputParams) throws Throwable JavaDoc
15     {
16         
17         int rc = super.service(inputParams);
18         
19         /* create a recordset with ChartInfo column structure */
20         Recordset rs = getChartInfoRecordset();
21
22         /* set chart configuration parameters */
23         rs.addNew();
24         rs.setValue("title", "Total Sales by Category");
25         rs.setValue("title-x", "Category"); //irrelevant for pie charts
26
rs.setValue("title-y", "Sales in US$"); //irrelevant for pie charts
27
rs.setValue("column-x", "categoryname");
28
29
30         //if multiseries then type multiple column names separated by ";"
31
rs.setValue("column-y", "subtotal");
32
33         rs.setValue("title-series", null); //no series - otherwise set label names separated by ";"
34
rs.setValue("width", new Integer JavaDoc(500)); //in pixels
35
rs.setValue("height", new Integer JavaDoc(350)); //in pixels
36
rs.setValue("data", "sales.sql"); //recordset that must be stored in session attribute
37

38         /* select the type of chart you want to use */
39         rs.setValue("chart-plugin", "dinamica.charts.HorizontalBarChart");
40         
41         /* publish recordset to be consumed by output module */
42         publish("chartinfo", rs);
43         
44         return rc;
45         
46     }
47
48 }
49
Popular Tags