如何在同一个 JFreeChart 中的 2 个 TimeSeriesCollection 之间切换

发布于 2024-12-24 18:20:14 字数 537 浏览 3 评论 0原文

在我的程序中,我需要显示 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

街角迷惘 2024-12-31 18:20:14

此处所示,使用TimeSeriesCollection创建图表。只要您有不同的 TimeSeries 实例,就可以使用 removeSeries()addSeries() 根据需要交换它们。 ChangeListener 将是 调整 相应。您仍然可以将数据添加到任一系列。

如果您仍然遇到问题,请编辑您的问题以包含 sscce

As shown here, create your chart with a TimeSeriesCollection. As long as you have distinct TimeSeries instances, you can use removeSeries() and addSeries() to swap them as required. The ChangeListener 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文