Hi all,
can someone try to tell me what i am doing wrong here?
private void drawJFreeChart(String iface, double[] tiv, double[] tov)
{
long[] dates = DataStore.getDateTimes(iface);
BasicTimeSeries i = new BasicTimeSeries("bla", Millisecond.class);
BasicTimeSeries o = new BasicTimeSeries("fasel", Millisecond.class);
for (int i = 0; i < dates.length; i++)
{
i.add(new FixedMillisecond(dates), tiv);
o.add(new FixedMillisecond(dates), tov);
}
TimeSeriesCollection t = new TimeSeriesCollection();
t.addSeries(i);
t.addSeries(o);
JFreeChart jfc = ChartFactory.createTimeSeriesChart("Karte " + iface, "dates",
"values", t, true);
ChartPanel cp = new ChartPanel(jfc);
jPanel2.add("Center", cp);
}
I am trying to draw XY Data based on long timestamps as in System.currentTimeMillis() The Series should hold a Pair every 5 Minutes.
I am getting:
com.jrefinery.data.SeriesException: TimeSeries.add(...): inconsistent time period class
Any help is highly appreciated
FixedMillisecond
Re: FixedMillisecond
You've defined your series to use the Millisecond class, then tried to add a FixedMillisecond.
The difference between these two is related to time zones. FixedMillisecond is like java.util.Date, it represents one moment in time, irrespective of the time zone. Once you specify a time zone, you can convert it to a date and time. I would have used java.util.Date, but I need to subclass TimePeriod.
Millisecond goes the other way. It represents a particular millisecond (0-999) within a Second (0-59), within a Minute (0-59), within an Hour (0-23), within a Day. The Day "floats", and you have to peg it to a TimeZone before you can translate the start and end of the day (TimePeriod) to a java.util.Date.
Does that make sense?
Regards,
DG.
The difference between these two is related to time zones. FixedMillisecond is like java.util.Date, it represents one moment in time, irrespective of the time zone. Once you specify a time zone, you can convert it to a date and time. I would have used java.util.Date, but I need to subclass TimePeriod.
Millisecond goes the other way. It represents a particular millisecond (0-999) within a Second (0-59), within a Minute (0-59), within an Hour (0-23), within a Day. The Day "floats", and you have to peg it to a TimeZone before you can translate the start and end of the day (TimePeriod) to a java.util.Date.
Does that make sense?
Regards,
DG.