简体   繁体   中英

JFreeCharts TimeSeriesCharts without X value

How to create TimeSeriesChart with constant distance for domain Axis (X values), just like LineChart but with DateAxis?

Normal TimeSeriesChart looks like this:

在此处输入图片说明

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...

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

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.

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.

If you have significant gaps in the domain, you could try a CombinedRangeXYPlot with a subplot for each contiguous time interval.

Addendum: Also, consider either or both of these settings for pan & zoom, illustrated here .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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