Valeria
Valeria

Reputation: 776

MPAndroidChart how to always show the last point in viewport?

I am using MPAndroidChart.

Here https://github.com/PhilJay/MPAndroidChart/wiki/Modifying-the-Viewport i found that we can use moveViewToX(float xIndex) (Moves the left side (edge) of the current viewport to the specified x-index). But if i need to show the last point always and does not matter how much the points there are?

Now i use moveViewToX(500); with the huge number as argument even if i have just 50 points, and its work. BUT, it is not right i think!

Upvotes: 2

Views: 2063

Answers (2)

Tim Seegmüller
Tim Seegmüller

Reputation: 61

You could also use

lineChart.moveViewToX(lineChart.getXChartMax());

Upvotes: 2

Philipp Jahoda
Philipp Jahoda

Reputation: 51421

Why not use

int numberOfYourEntries = ...; // get the number
chart.moveViewTo(numberOfYourEntries);

Upvotes: 2

Related Questions