JFreeChart TimeSeries Chart remove days with no value

扶醉桌前 提交于 2019-12-13 13:11:42

问题


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?


回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!