1

Can I include a horizontal scroll bar to view the previous data in a JFreechart? I am using linechart graph to draw dynamic graph and showing 10 values on x-axis at a time, I want to view the graph with a horizontal scroll bar.

How can I set the values for scrollbar to view the previous data?

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
shivshankar
  • 691
  • 2
  • 14
  • 31

1 Answers1

2

Several options are available:

  • Adding your ChartPanel to a JScrollPane,

  • Using a SlidingXYDataset, mentioned here,

  • Using a paging approach, illustrated here.

  • Addendum: Using a SlidingCategoryDataset with ChartFactory.createLineChart().

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Hi @trashgod. Thanks for your quick reply. Sorry,i have edited my post. Actually i am using Linechart because i am having numeric values both on x-axis and y-axis. In case of timeseries i can get minimum value of domainaxis and then as per scrollbar value i can show records on graph area. But in this case of Linechart can you please suggest me how would i able to see my previous data? – shivshankar Aug 04 '12 at 18:18
  • Even easier: `SlidingCategoryDataset` is covered in the [demo](http://www.jfree.org/jfreechart/samples.html). – trashgod Aug 04 '12 at 18:34
  • My x-axis values fall between -3 to 3. so how will i move backward to get previous values? – shivshankar Aug 04 '12 at 18:59
  • I never tried that. Which approach have you decided to pursue? Please edit your question to include the latest requirements and an [sscce](http://sscce.org/) that shows your current approach. – trashgod Aug 04 '12 at 19:20