KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > transactions > TimeSeries


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 TimeSeries 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         Recordset x = new Recordset();
27         x.append("date", java.sql.Types.DATE);
28         x.append("value", java.sql.Types.DOUBLE);
29         
30         for (int i=0;i<6;i++)
31         {
32             
33             java.util.Date JavaDoc d = null; // StringUtil.getDateObject("2003-11-01", "yyyy-MM-dd");
34
java.util.Calendar JavaDoc c = java.util.Calendar.getInstance();
35             c.add(java.util.Calendar.DATE,i+1);
36             d = c.getTime();
37             Double JavaDoc dbl = new Double JavaDoc((double)1000.00 + (i*2000));
38             x.addNew();
39             x.setValue("date",d);
40             x.setValue("value", dbl);
41         }
42
43         getSession().setAttribute("timeseries", x);
44         
45         /* create a recordset with ChartInfo column structure */
46         Recordset rs = getChartInfoRecordset();
47
48         /* set chart configuration parameters */
49         rs.addNew();
50         rs.setValue("title", "Compras Anuales");
51         rs.setValue("title-x", "D�a"); //irrelevant for pie charts
52
rs.setValue("title-y", "Monto en US$"); //irrelevant for pie charts
53
rs.setValue("column-x", "date");
54         rs.setValue("column-y", "value"); //if multiseries then type multiple column names separated by ";"
55
rs.setValue("title-series", null); //no series - otherwise set label names separated by ";"
56
rs.setValue("width", new Integer JavaDoc(600)); //in pixels
57
rs.setValue("height", new Integer JavaDoc(400)); //in pixels
58
rs.setValue("data", "timeseries"); //recordset that must be stored in session attribute
59
rs.setValue("dateformat", "dd-MM-yyyy"); //recordset that must be stored in session attribute
60

61         /* select the type of chart you want to use */
62         rs.setValue("chart-plugin", "dinamica.charts.VerticalBarChart3D");
63         
64         /* publish recordset to be consumed by output module */
65         publish("chartinfo", rs);
66         
67         return rc;
68         
69     }
70
71 }
72
Free Books   Free Magazines  
Popular Tags