Chart un-zoomed
Chart zoomed
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?
I tried this:
Code: Select all
org.jfree.data.Range xRange = plot.getDomainAxis().getRange();
org.jfree.data.Range yRange = plot.getRangeAxis().getRange();
ConsoleLog.DisplayToConsole(xRange.toString());
Code: Select all
int width = 640; /* Width of the image */
int height = 480; /* Height of the image */
File file = new File( "LineChart.jpeg" );
try {
ChartUtilities.saveChartAsJPEG(file ,lineChart, width ,height);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Thanks
Update:
I've found what I wanted:
Code: Select all
XYSeries series = data.getSeries(0);
org.jfree.data.Range xRange = plot.getDomainAxis().getRange();
int x = (int) xRange.getLowerBound();
int y = (int) xRange.getUpperBound();
ArrayList<String> list = new ArrayList<String>();
String s = "";
for(int i = x; i < y; i++)
{
s = String.valueOf(series.getY(i));
list.add(s);
ConsoleLog.DisplayToConsole(s);
}