Returning the data displayed in the line chart current view

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
duyvh0309
Posts: 2
Joined: Thu Jul 09, 2020 3:16 am
antibot: No, of course not.

Returning the data displayed in the line chart current view

Post by duyvh0309 » Thu Jul 09, 2020 3:20 am

Hi I have created the following line chart:

Chart un-zoomed
Image

Chart zoomed
Image

I created the chart with XYSeriesCollection then added to it three XYSeries. The chart works great and I can zoom in and pan left and right.

My problem is that I'm trying to save the data currently displayed in the chart view for each of the datasets (in this case 3). The chart data is big so when a user is able to zoom in on a section I want them to be able to save the data shown in that section. I would appreciate help with this?

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Returning the data displayed in the line chart current view

Post by John Matthews » Mon Jul 27, 2020 7:42 pm

Examine the chart's XYPlot to learn the current range of the desired axis:

Code: Select all

Range domain = chart.getXYPlot().getDomainAxis().getRange();
Range range = chart.getXYPlot().getRangeAxis().getRange();
Use the range values to iterate over the dataset. DatasetUtils illustrates typical iteration schemes.

Locked