KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > transactions > TotalsChart


1 package transactions;
2
3 import dinamica.*;
4
5 /**
6  * Demo Charting Transaction
7  *
8  * <br>
9  * Creation date: 29/10/2003<br>
10  * Last Update: 29/10/2003<br>
11  * (c) 2003 Martin Cordova<br>
12  * This code is released under the LGPL license<br>
13  * @author Martin Cordova
14  * */

15 public class TotalsChart extends GenericTransaction
16 {
17
18     /* (non-Javadoc)
19      * @see dinamica.GenericTransaction#service(dinamica.Recordset)
20      */

21     public int service(Recordset inputParams) throws Throwable JavaDoc
22     {
23         
24         int rc = super.service(inputParams);
25         
26         /* create a recordset with ChartInfo column structure */
27         Recordset rs = getChartInfoRecordset();
28
29         /* set chart configuration parameters */
30         rs.addNew();
31         rs.setValue("title", "Ventas Totales por Año y Categoría");
32         rs.setValue("title-x", "Categoría"); //irrelevant for pie charts
33
rs.setValue("title-y", "Monto en US$"); //irrelevant for pie charts
34
rs.setValue("column-x", "categoryname");
35         rs.setValue("column-y", "s1;s2;s3"); //if multiseries then type multiple column names separated by ";"
36
rs.setValue("title-series", "1994;1995;1996"); //no series - otherwise set label names separated by ";"
37
rs.setValue("width", new Integer JavaDoc(680)); //in pixels
38
rs.setValue("height", new Integer JavaDoc(400)); //in pixels
39
rs.setValue("data", "total_per_year.sql"); //recordset that must be stored in session attribute
40

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