TimeSeriesChart Question!

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
t3en4
Posts: 3
Joined: Tue May 20, 2008 2:09 pm

TimeSeriesChart Question!

Post by t3en4 » Tue May 20, 2008 2:16 pm

hi there...

im trying to create a multiple data set TimeSeriesChart.... the thing is, i recolect data from a data base (datatime (TIMESTAMP) , value (DOUBLE)) ... but, i have values recolected that have same timestamps in my DB (wich is suposse to be like that...), something like this:


+-------------+-----------+---------------------+
| template_id | value | datatime |
+-------------+-----------+---------------------+
| 1 | 2.2 | 2008-05-09 09:29:00 |
| 1 | 1.7 | 2008-05-09 09:22:00 |
| 1 | 1.2 | 2008-05-09 09:15:00 |
| 1 | 0.7 | 2008-05-09 09:08:00 |
| 1 | 0.2 | 2008-05-09 09:01:00 |
| 2 | 4 | 2008-05-09 09:29:00 |
| 2 | 3 | 2008-05-09 09:22:00 |
| 2 | 2 | 2008-05-09 09:15:00 |
| 2 | 1 | 2008-05-09 09:08:00 |
| 2 | 0 | 2008-05-09 09:01:00 |
| 3 | 3.1000001 | 2008-05-09 09:29:00 |
| 3 | 2.4 | 2008-05-09 09:22:00 |
| 3 | 1.7 | 2008-05-09 09:15:00 |
| 3 | 1 | 2008-05-09 09:08:00 |
| 3 | 0.3 | 2008-05-09 09:01:00 |
+-------------+-----------+---------------------+

but i get this error:

org.jfree.data.general.SeriesException: You are attempting to add an observation for the time period 20-mayo-2008 but the series already contains an observation for that time period. Duplicates are not permitted.

who can i let jfreechart to draw my graphics no matter if the period of other serie is duplicated...

thx.

ps: does anyone knows how to do timeseries chart in iReports? i only get doted lines (i suposse its because the same reason: i cant duplicate periods).... thx

indio
Posts: 17
Joined: Thu Mar 27, 2008 4:14 pm

Post by indio » Tue May 20, 2008 2:34 pm

Finally something that even I can answer :).

you an do a series.addOrUpdate() instead of add(). It will overwrite previous values.

t3en4
Posts: 3
Joined: Tue May 20, 2008 2:09 pm

Post by t3en4 » Tue May 20, 2008 2:37 pm

lol !!! thx... im glad u understand even w/my terrible english...

i have other question... i get from my DB a timestamp (thats what i want to put on my X axis)... (i want that it shows like: 09:00:00 09:00:20 .... and so on)...

how should i pass the parameter to the addorupdate?



series.addOrUpdate( <timestamp> , new Double(rs.getString("value")));

timstamp: rs.getString("datatime") ....

THXXXXXXXXXXX :D

jpmaia
Posts: 53
Joined: Fri Feb 22, 2008 10:44 pm

Post by jpmaia » Tue May 20, 2008 9:59 pm

Or ... instead of using "TimeSeries..." classes, use "TimePeriod..." classes. They allow duplicates in the data.

t3en4
Posts: 3
Joined: Tue May 20, 2008 2:09 pm

Post by t3en4 » Tue May 20, 2008 10:50 pm

i know that, but i need to somehow put my timestamp (specificly the time part: hh:mm:ss) on the timseries constructor, but, the first parameter is an regulartime period or something like that...

thx :D


:P

Locked