Creating a time series with jfreechart

三世轮回 提交于 2019-12-17 06:55:09

问题


Right now I want to create a time series graph in jfreechart. However the examples online only have charts using classes like "Day", "Month", and so on. So I want to essentially create a XY line chart. However the problem I'm having is that Jfreechart doesn't connect the data points in the order in which they were added. Also it doesn't connect the points in the order of the "X Values". So basically I get a "Z" in my jfreechart.

So my question is, is there a way to change the setting for the jfreechart so that it connects the data points based on the "X values"?


回答1:


You might have a look at org.jfree.chart.demo.TimeSeriesChartDemo1, and the associated API documentation. A typical command to run the demo might look like this:

java -cp lib/jfreechart-1.0.13.jar:lib/jcommon-1.0.16.jar \
org.jfree.chart.demo.TimeSeriesChartDemo1

The example uses org.jfree.data.time.Month to represent monthly data, but other units are available in org.jfree.data.time. See also the approach shown in this related example, which is based on TimeSeriesChartDemo1.



来源:https://stackoverflow.com/questions/2602696/creating-a-time-series-with-jfreechart

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