使用 JFreeChart 显示时间序列中的最近变化
如何使用 JFreeChart
连续显示最新数据更新时间序列?
附录:此处显示了包含已接受答案的完整、有效的示例。另请参阅具有两个系列的变体。另请参阅有关 setTimeBase()
的问答。
How can I use JFreeChart
to display just the most recent data in a continually updated time series?
Addenda: A complete, working example that incorporates the accepted answer is shown here. See also this variation having two series. See also this Q&A regarding setTimeBase()
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
JFreeChart
类JFreeChart
类jfree.org/jfreechart/api/javadoc/org/jfree/data/time/DynamicTimeSeriesCollection.html" rel="nofollow noreferrer">DynamicTimeSeriesCollection
是一个不错的选择。附录:正如@Bahadır 所指出的,该系列的最后一点始终为零。 @Don 很有帮助地建议提前时间并然后附加数据。
The
JFreeChart
classDynamicTimeSeriesCollection
is a good choice.Addendum: As noted by @Bahadır, the last point of the series was persistently zero. @Don helpfully suggests advancing the time and then appending the data.
您还可以先通过
advanceTime()
消除零,然后通过appendData
消除零。 (交换他们在示例中的操作方式)。You can also eliminate the zero by first
advanceTime()
, thenappendData
. (swap the way they are doing it in the example).@thrashgod 答案的另一种方法是使用 TimeSeriesCollection 并在 TimeSeries 上设置项目年龄。下面的代码可以设置一个图表,以 1 分钟的间隔显示最近 1 小时的数据。
..您将添加附带的数据:
One alternative approach to @thrashgod's answer would be to use
TimeSeriesCollection
and setting item age on theTimeSeries
. Below code can setup a graph to show last 1 hour of data with 1 minute intervals...and you will add the data as it comes with: