Trouble using Minute class in TimeSeries

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Pat

Trouble using Minute class in TimeSeries

Post by Pat » Mon Feb 11, 2002 5:34 pm

Can someone tell me if I am doing something wrong here? I am trying to create a time series chart based on minutes. I am using this code:

TimeSeriesCollection data = new TimeSeriesCollection();
BasicTimeSeries data1 = new BasicTimeSeries("Web Server");

try{
Day day = new Day(1,SerialDate.JANUARY,2002);
data1.add(new Minute(30,day),new Double(0.0));
data1.add(new Minute(60,day),new Double(1.0));
data1.add(new Minute(90,day),new Double(2.0));
data1.add(new Minute(120,day),new Double(0.0));
}

I get this error:

TimeSeries.add(...): inconsistent time period class.

If I change it to a Day based time series, like below, it works fine. I couldn't find any other problems listed that were similar.

data1.add(new Day(1,SerialDate.JANUARY,2002),new Double(0.0));
data1.add(new Day(2,SerialDate.JANUARY,2002),new Double(1.0));
data1.add(new Day(3,SerialDate.JANUARY,2002),new Double(2.0));
data1.add(new Day(4,SerialDate.JANUARY,2002),new Double(0.0));

David Gilbert

Re: Trouble using Minute class in TimeSeries

Post by David Gilbert » Mon Feb 11, 2002 6:34 pm

Hi Pat,

Every BasicTimeSeries instance has a time period class. The constructor you have used creates a daily time series. You need to change the line to:

BasicTimeSeries data1 = new BasicTimeSeries("Web Server", Minute.class);

I couldn't think of a better way to prevent people from mixing different subclasses of TimePeriod in one series...

Regards,

DG.

Locked