问题
Is there a simple way to remove days with no value?
Here is some of my data12-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?
回答1:
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:

Ommiting the 14th
来源:https://stackoverflow.com/questions/10740020/jfreechart-timeseries-chart-remove-days-with-no-value