Search code examples
jfreechart

Setting date range in DynamicTimeSeriesCollection horizontal axis


I am now working on a DynamicTimeSeriesCollection chart which display energy value in Y-axis, and X-axis should be date.

 private final Second time = new Second();
 private final DynamicTimeSeriesCollection dataset = new DynamicTimeSeriesCollection(1, 180, time);

The JFreeChart display a tick every 1/2 second automatically as the following example!

00:13:00
00:13:30
00:14:00
00:14:30

How can I change them by my customized value as:

00:13:00---> 01-Jan-2011
00:13:30---> 02-Jan-2011
00:14:00---> 03-Jan-2011
00:14:30---> 04-Jan-2011

(1 default second = 2 days in my case).

I can't find any solution, could any one help?


Solution

  • OK. Finally i resolved my question by using TimeSeries. We can create a dataset as we need:

        TimeSeries s1 = new TimeSeries("L&G European Index Trust");
    
        s1.add(new Day(1, 1, 2001), 181.8);       
        s1.add(new Day(3, 1, 2001), 181.8);
        s1.add(new Day(5, 1, 2001), 167.3);
        s1.add(new Day(7, 1, 2001), 153.8);
    

    In TimeSeries we can control dataset, i means value and date better than DynamicTimeSeriesCollection.