4

I have an Android application that is using Achart to create a 2 graphs. Both a line graph and a bar graph. These graph will be populated with an extra data point each time the application is run. So after 10 runs there will be enough data to cover the visible x-axis.

What I want is for after the 11th+ use, to be able to pan the graph, so that the user can see historical data (back to the first data point). I have set

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

Which is all good, but when I pan the data I am able to pan to -ve values on the x axis, and also able to pan way beyond the maximum data point that I already have.

I have tried setting a PanListener, which I think is the way to go, but I am just not sure what I should be setting in this Listener to clamp the panning to valid data points only.

Any ideas?

Matt
  • 53
  • 6

1 Answers1

3

The user pan will just modify the X axis min and max. In order to avoid this, you will have to indeed add a PanListener and reset these values.

You can also set pan limits.

renderer.setPanLimits(limits);
Dan D.
  • 32,246
  • 5
  • 63
  • 79
  • A quick update. With my setup I didn't need to use the `PanListener` after all. I was able to add this `setPanLimits` call to the renderer in the initial setup of the charts. – Matt Feb 24 '13 at 11:03