java 使用 jfreechart 创建时间序列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2602696/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 21:59:38  来源:igfitidea点击:

Creating a time series with jfreechart

javajfreechart

提问by Albinoswordfish

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.

现在我想在 jfreechart 中创建一个时间序列图。但是,在线示例只有使用“日”、“月”等类的图表。所以我想基本上创建一个 XY 折线图。但是,我遇到的问题是 Jfreechart 没有按照添加顺序连接数据点。它也不会按照“X 值”的顺序连接点。所以基本上我在我的 jfreechart 中得到一个“Z”。

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"?

所以我的问题是,有没有办法更改 jfreechart 的设置,以便它根据“X 值”连接数据点?

回答by trashgod

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:

您可能会查看org.jfree.chart.demo.TimeSeriesChartDemo1和相关的API 文档。运行演示的典型命令可能如下所示:

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

image

图片

The example uses org.jfree.data.time.Monthto 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.

该示例用于org.jfree.data.time.Month表示每月数据,但其他单位在org.jfree.data.time. 另请参阅此相关示例中显示的方法,该方法基于TimeSeriesChartDemo1.