如何在同一个 JFreeChart 中的 2 个 TimeSeriesCollection 之间切换
在我的程序中,我需要显示 JFreeChart。 随着时间的推移,我正在向该 JFreeChart 添加系列。 我有一棵树,它允许我在不同的项目之间切换并将它们显示在图表中。我所做的是更新 TimeSeriesCollection。 (使用新数据完全更新或重置)
但是我需要在特定情况下将数据添加到我的项目之一,从而使用新数据显示图表,同时,用户可能更改项目并且程序仍然需要在显示第二个项目的同时更新我的第一个项目。
这意味着我有一个“Item1”图表,我随着时间的推移向其中添加数据,在这样做的同时,我希望能够切换到“Item2”并在图表中显示该项目(同时仍然添加我的数据到“item1”)
我很难使用其他 TimeSeriesCollections 来放置新数据,同时显示第一个 TimeSeriesCollections。但我似乎找不到在 2 个 TimeSeriesCollection 之间切换的方法.. 就像 myJFreeChart.setTimeSeriesCollection(TimesSeriesCollections tsc)
有什么想法吗?
In my program I need to display a JFreeChart.
I'm adding, over time, series to that JFreeChart.
I'm having a tree who allows me to switch between different item and displaying them in the chart. What i do is that I update the TimeSeriesCollection. (Update or reset completely with new data)
But I need in a specific case to add data to one of my item, thus displaying the chart with the new data, and at the same time, the user might change item and the program still needs to update my 1st item while displaying the second.
Which mean i have a graph of "Item1" to which I'm adding data over time, and while doing that, i want to be able to switch to an "Item2" and displaying that item in the graph (while still adding my data to "item1")
I tough about using an other TimeSeriesCollections to wich i could put the new data while displaying the first TimeSeriesCollections. But i can't seem to find a way to switch between 2 TimeSeriesCollection.. like a myJFreeChart.setTimeSeriesCollection(TimesSeriesCollections tsc)
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如此处所示,使用
TimeSeriesCollection
创建图表。只要您有不同的TimeSeries
实例,就可以使用removeSeries()
和addSeries()
根据需要交换它们。ChangeListener
将是 调整 相应。您仍然可以将数据添加到任一系列。如果您仍然遇到问题,请编辑您的问题以包含 sscce。
As shown here, create your chart with a
TimeSeriesCollection
. As long as you have distinctTimeSeries
instances, you can useremoveSeries()
andaddSeries()
to swap them as required. TheChangeListener
will be adjusted accordingly. You can still add data to either series.If you're still having problems, edit your question to include an sscce.