简体   繁体   English

没有X值的JFreeCharts TimeSeriesCharts

[英]JFreeCharts TimeSeriesCharts without X value

How to create TimeSeriesChart with constant distance for domain Axis (X values), just like LineChart but with DateAxis? 如何为域Axis(X值)创建具有恒定距离的TimeSeriesChart,就像LineChart一样,但使用DateAxis?

Normal TimeSeriesChart looks like this: 正常的TimeSeriesChart看起来像这样:

在此处输入图片说明

But I need something like: 但是我需要这样的东西:

在此处输入图片说明

with Date Axis on the bottom 日期轴在底部

Chart data are changing very frequently, and when I'm using simple LineChart domain axis is unreadable... 图表数据变化非常频繁,并且当我使用简单的LineChart域轴时无法读取...

I've created some class extending XYSeries which sets next values to X and I've changed number formatter to render specific date, but this solution is just bad workaround 我创建了一些扩展XYSeries的类,该类将下一个值设置为X,并且我更改了数字格式器以呈现特定的日期,但是这种解决方案只是不好的解决方法

Rather than extending XYSeries try setting XYSeries#setMaximumItemCount(int) to the maximum number of items that you want to show in you chart this will stop the chart becoming unreadable. 与其扩展XYSeries尝试将XYSeries#setMaximumItemCount(int)设置为要在图表中显示的最大项目数,这将使图表变得不可读。

In your second screen it looks like you are using a constant x interval, if you time are constant you will get a chart like this, if not use an integer axis otherwise you will get irregular steps. 在第二个屏幕中,您似乎正在使用恒定的x间隔,如果时间恒定,则将获得如下所示的图表,如果不使用整数轴,则将得到不规则的步长。

If you have significant gaps in the domain, you could try a CombinedRangeXYPlot with a subplot for each contiguous time interval. 如果您在域中有很大的差距,可以尝试对每个连续时间间隔使用带有子图的CombinedRangeXYPlot

Addendum: Also, consider either or both of these settings for pan & zoom, illustrated here . 附录:另外,还要考虑这些设置的平移和缩放,说明一方或双方在这里

plot.setDomainPannable(true);
chartPanel.setMouseWheelEnabled(true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM