Domanda

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?

È stato utile?

Soluzione

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);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top