Gimmy88
Gimmy88

Reputation: 305

Android - How to Align Point in the Center of Graph?

i'm user achartengine to plot a graph. When i plot more than 1 point there are no problem, because evrey point is shown in the graph, but when the point is only one it is align on the left side of the graph, on the X axis and it isn't shown.

enter image description here

So how to move that point in the center of the graph?

Thx in advance!

Upvotes: 1

Views: 211

Answers (1)

Dan D.
Dan D.

Reputation: 32391

After adding the first point, supposing that the location of the point is at x, y, do the following:

renderer.setXAxisMin(x - 1);
renderer.setXAxisMax(x + 1);
renderer.setYAxisMin(y - 1);
renderer.setYAxisMax(y + 1);

or the short version:

renderer.setRange(new double[] {x - 1, x + 1, y - 1, y + 1}, 0);

Later, when you add the second point, just make sure you either set other visible ranges using the approach above or reset the visible ranges using this:

renderer.setRange(new double[] {MathHelper.NULL_VALUE, MathHelper.NULL_VALUE, MathHelper.NULL_VALUE, MathHelper.NULL_VALUE}, 0);

Upvotes: 1

Related Questions