Getting the zoom range
Getting the zoom range
After zooming I would like to have the starting point, ending point and number of points of the zoomed image. How do I get them?
Re: Getting the zoom range
After zooming, all that happens is the range on each axis is adjusted. You can find out the current range for each axis using the getRange() method in the ValueAxis class:
XYPlot plot = myChart.getXYPlot();
ValueAxis axis = plot.getDomainAxis();
Range range = axis.getRange();
The data in your dataset is not altered in any way. To find out how many points are displayed on the chart, you would have to iterate through all the data items and check whether or not they fall within the current axis ranges.
Regards,
Dave Gilbert
XYPlot plot = myChart.getXYPlot();
ValueAxis axis = plot.getDomainAxis();
Range range = axis.getRange();
The data in your dataset is not altered in any way. To find out how many points are displayed on the chart, you would have to iterate through all the data items and check whether or not they fall within the current axis ranges.
Regards,
Dave Gilbert
Re: Getting the zoom range
This appears to get me close. However sometimes either the first or last point are not included.
double visible_low_point = io_graph.chart.getXYPlot().getDomainAxis().getRange().getLowerBound();
double visible_hi_point = io_graph.chart.getXYPlot().getDomainAxis().getRange().getUpperBound();
System.out.print("visible number of points: " + view + "\n");
int first_zoomed = (int)((((visible_low_point - total_ios_graph_low_point)/total_ios_graph_range) * my_x)+.99);
System.out.print("first zoomed point: " + first_zoomed + "\n");
int last_zoomed = (int)((((visible_hi_point - total_ios_graph_low_point)/total_ios_graph_range) * my_x)+.99);
System.out.print("last zoomed point: " + last_zoomed + "\n");
Is there a way to get the explicit location of the domainAxis for a given data point? Your response regarding iterating through the data implies it.
double visible_low_point = io_graph.chart.getXYPlot().getDomainAxis().getRange().getLowerBound();
double visible_hi_point = io_graph.chart.getXYPlot().getDomainAxis().getRange().getUpperBound();
System.out.print("visible number of points: " + view + "\n");
int first_zoomed = (int)((((visible_low_point - total_ios_graph_low_point)/total_ios_graph_range) * my_x)+.99);
System.out.print("first zoomed point: " + first_zoomed + "\n");
int last_zoomed = (int)((((visible_hi_point - total_ios_graph_low_point)/total_ios_graph_range) * my_x)+.99);
System.out.print("last zoomed point: " + last_zoomed + "\n");
Is there a way to get the explicit location of the domainAxis for a given data point? Your response regarding iterating through the data implies it.
Re: Getting the zoom range
"...The data in your dataset is not altered in any way. To find out how many points are displayed on the chart, you would have to iterate through all the data items and check whether or not they fall within the current axis ranges.
What gives the location of a data item on the axis?
What gives the location of a data item on the axis?