jmichal
jmichal

Reputation: 11

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:

enter image description here

But I need something like:

enter image description here

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

Upvotes: 1

Views: 121

Answers (2)

trashgod
trashgod

Reputation: 205785

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);

Upvotes: 1

GrahamA
GrahamA

Reputation: 5923

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.

Upvotes: 1

Related Questions