1

I am using JFreeChart in my java application.

Problem

I want to plot a XYAreaChart whose domain axis (x-axis) should scroll horizontally automatically when we start plotting the data.

I saw the same thing in TimeSeriesCharts but I don't want any timeSeriesChart. I just want the scrolling x-axis.

Amit
  • 33,847
  • 91
  • 226
  • 299

1 Answers1

2

You'll need to create your own SlidingXYDataset that implements XYDataset in a manner similar to how SlidingCategoryDataset implements CategoryDataset.

Addendum: As noted in a comment, a typical implementation can be found here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • I found one patch for it at http://sourceforge.net/tracker/index.php?func=detail&aid=2439953&group_id=15494&atid=315494 but I have one problem in it when I want to set my own range of X-axis. This example works fine with plot.getDomainAxis().setAutoRange(true).. but I want to set my own range for x-axis. – Amit Mar 24 '11 at 07:22
  • It's a little dated, but it works. What's wrong with `setFirstItemIndex()`? IF you want a fixed domain range, see this [DynamicTimeSeriesCollection example](http://stackoverflow.com/questions/5048852). – trashgod Mar 24 '11 at 07:59
  • Sorry, I did *not* want to downvote this answer. Is it possible to correct this? – Shadow Nov 19 '14 at 13:39