Limit panning of an AChart engine to valid data points

I have an Android app that uses Achart to create two charts. Both a linear graph and a histogram. This graph will be filled with an additional data point each time the application is launched. Thus, after 10 starts, there will be enough data to cover the visible x axis.

I want it after the 11th + use to pan the graph so that the user can see the historical data (back to the first data point). I have installed

renderer.setPanEnabled(true, false); renderer.setZoomEnabled(false, false); renderer.setYAxisMin(0); renderer.setXAxisMin(0.5); renderer.setXAxisMax(10.5); renderer.setYAxisMax(100); 

That is all good, but when I look at the data, I can pan the -ve values โ€‹โ€‹on the x axis, as well as the ability to pan above the maximum data point that I already have.

I tried to install a PanListener, which seems to fit, but I'm just not sure what I should install in this Listener in order to fix the pan only for valid data points.

Any ideas?

+4
source share
1 answer

The user panorama will simply change the X min and max axis. To avoid this, you really need to add the PanListener and reset values.

You can also set pan restrictions.

 renderer.setPanLimits(limits); 
+3
source

All Articles