JFreeChart SlidingCategoryDataset图表仅更新轴 [英] JFreeChart SlidingCategoryDataset chart update only axis

查看:91
本文介绍了JFreeChart SlidingCategoryDataset图表仅更新轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了盒子和晶须图,其中包含来自一个csv文件.
它具有许多类别,并且在屏幕上显示得非常紧.
因此,我决定在此处中使用带有JSlider的SlidingCategoryDataset.

I have implemented a Box and Whisker Chart with data from a csv file.
It has many categories and was displayed very squeezed on the screen.
So I decided to use a SlidingCategoryDataset with a JSlider as mentioned here.

我认为我的新类带有SlidingCategoryDataset的代码,该类扩展了DefaultBoxAndWhiskerDataset,因为x轴上的类别标签已正确更新,因此可以正常工作.但是图表中的条形保持不变,无论我做什么都不会随时更新.更令人困惑的是,这些工具栏的工具提示确实可以正确更新.
当我使用滑块到达数据集的末尾并显示例如一次有10个类别,例如图表仅剩9个,图表正确显示了9个柱,但不是隐藏第一个柱,而是隐藏了最后一个柱(轴和工具提示已正确更新).

I think my new class with code from SlidingCategoryDataset that extends DefaultBoxAndWhiskerDataset works fine because the category labels on the x-axis are updated correctly. BUT the bars in the chart stay the same and do not update anytime no matter what I do. Even more confusing is that the tool tips of the bars do update correctly.
When I reach the end of the dataset with the slider and display e.g. 10 categories at once and there are e.g. only 9 left, the chart displays 9 bars correctly but instead of hiding the first bar it hides the last bar (axis and tool tip are updated correctly).

我在Google上寻求了一个解决方案,但没有找到解决我问题的答案.因此,我自己使用所有可用的update和repaint方法进行了尝试,因为我认为这一定是GUI问题,但没有成功.您可以在这里查看我的更新方法:

I looked for a solutuion with google but did not find an answer for my problem. So I tried it by myself by using all avaible update and repaint methods because I think it must be a GUI problem but with no success. You can see my update method here:

private void sliderChanged(){
    int val = slider.getValue();
    sData.setFirstCategoryIndex(val);// my sliding dataset
    chart = ChartDrawer.draw(sData); // to draw chart again should be unnecessary
    chart.fireChartChanged();
    chartPanel.setChart(chart);
    chartPanel.revalidate();
    chartPanel.repaint();
    chartPanel.updateUI();
    repaint();
}

我现在有点绝望.有人可以帮我吗?还是有人知道另一种显示很多类别的方法,那是行得通的?
非常感谢.

I am a bit desperate now. Can somebody help me please? Or does somebody know another way to display many categories, that is working?
Thanks a lot.

推荐答案

分页方法有效,并且扩展性很好.所示示例使用按钮,但微调器或滑块也可以使用.

The paging approach works, and it scales well. The example shown uses buttons, but a spinner or slider would do as well.

或者,您可以将实现与 SlidingXYDataset 进行比较此处并在此处进行了讨论.

Alternatively, you could compare your implementation to the SlidingXYDataset, cited here and discussed here.

这篇关于JFreeChart SlidingCategoryDataset图表仅更新轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆