Reputation: 7343
I am building an Android Application and I am using AChartEngine to display a graph and values I obtain.
I am able to graph the values I have properly. However, once the user zooms in and pans around my graph, it becomes difficult to view the data. One option I considered is to display a "redraw graph" button where once the user clicks it, the graph would redraw itself to the original state, zoom and pan would also reset.
Here's by code thus far:
public void redrawGraph(View view){
chartView.repaint();
}
where redrawGraph
is a the onClick
function of my button and chartView
is an object of type GraphicalView
.
However, that does seem to do anything as it only repaints changes in my graph (if I added/removed series renderers, series, etc).
How can I reset the zoom and pan of graphs in AChartEngine?
Upvotes: 1
Views: 720
Reputation: 766
My answer refers to XY/time charts. First you have to enable the external zoom feature in every renderer you use. The snippet below shows the code for accomplishing this:
yourMultipleSeriesRenderer.setExternalZoomEnabled(true);
In your method redrawGraph
you then have to execute the command shown below:
public void redrawGraph(View view) {
chartView.zoomReset();
}
This works great for me. If you need any further information leave a comment.
Upvotes: 1
Reputation: 7209
Put this in your Multiple Series Render
multiRenderer.setZoomButtonsVisible(false);
// setting pan enablity which uses graph to move on both axis
multiRenderer.setPanEnabled(true, false);
// setting click false on graph
multiRenderer.setClickEnabled(false);
// setting zoom to false on both axis
multiRenderer.setZoomEnabled(true, false);
// setting lines to display on y axis
multiRenderer.setShowGridY(true);
// setting lines to display on x axis
multiRenderer.setShowGridX(true);
// setting legend to fit the screen size
multiRenderer.setFitLegend(true);
// setting displaying line on grid
multiRenderer.setShowGrid(true);
// setting zoom to false
multiRenderer.setZoomEnabled(false);
// setting external zoom functions to false
multiRenderer.setExternalZoomEnabled(false);
Upvotes: -2