Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JFreeChart TimeSeries Chart remove days with no value

Is there a simple way to remove days with no value? Here is some of my data
12-04-2012 => 15
13-04-2012 => 12
15-04-2012 => 10
16-04-2012 => 5

In chart 14-04-2012 is painted. I mean, theres a longer line between 13-04 and 15-04. Is it possible to have equal gaps between values?

like image 548
Astaz3l Avatar asked Nov 04 '22 23:11

Astaz3l


1 Answers

Are you using an TimeSeries (org.jfree.data.time.TimeSeries )? if so consider using a CategoryDataset (org.jfree.data.time.TimeSeries)

   private static CategoryDataset createDataset() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(15, "Series 1", "12-04-2012");
    dataset.addValue(12, "Series 1", "13-04-2012");
    dataset.addValue(10, "Series 1", "15-04-2012");
    dataset.addValue(5,  "Series 1",  "16-04-2012");
    return dataset;
} 

Using this data with JFreeChart Line Chart Demo 8 you will get this:

enter image description here

Ommiting the 14th

like image 164
GrahamA Avatar answered Nov 09 '22 13:11

GrahamA