0

I have a Database which stores every 15 minutes the temperature. Now i want to create a Java JFreeChart time series Chart, which displays the last 24 hours.

I imported the last 24 hours data with a mysql request into my java program. What is the easiest way to show all my data in the chart? Because when i try to add a new value , i get an error that its not allowed to have 2 times the same hour.

Here are some values from my database (for example)

2014-01-18 13:45:04  21.4  11.6
2014-01-18 13:30:03  20.8  10.3

How can i add them into a chart?

is there a method to add data with same days and same hours? because i only know the

timeseries.add(new Day(...))
timeseries.add(new Hour(..))

methods.

Thanks

Mike_NotGuilty
  • 2,253
  • 5
  • 32
  • 64

1 Answers1

2

In JFreeChart, the TimeSeries class works with RegularTimePeriod instances for the x-values. If you use the Day subclass of RegularTimePeriod, it means your time series has daily observations...so for a given day, you can only have at most one observation. Likewise, if you use the Hour subclass, your TimeSeries has hourly observations, at most one will be permitted for any given hour.

You can add your data using one of the other RegularTimePeriod subclasses that allows more precision (that is, Minute, Second or Millisecond).

David Gilbert
  • 4,427
  • 14
  • 22
  • I will try that. thanks... are there other chart types where i can set my own x axis? so i could say first value x-axis - Jan 17th, 5 AM , 14th value x-xis - Jan 17th, 9PM,... for example – Mike_NotGuilty Jan 19 '14 at 12:27