How to auto scroll MPAndroidChart line chart?

I am a new user of MPAndroidChart in android. can anyone help me?

+3


source to share


1 answer


So, what do you want to do, it always shows 10 values ​​in the chart, no matter how many values ​​are stored in the object LineData

?

You can do this by holding the view on the horizontal (x) axis and then aim the view at the data you want to see. So you need to call

setScaleMinima((float) lineData.getXValCount() / 10f, 1f)

This constrains the x-axis view and always displays exactly 10 values. You can then indicate what your gaze should be aiming for by calling

centerViewPort(float val, int xindex)



If you call centerViewPort (500f, 11), your view will target the y-value of 500 (on the vertical axis) and the 11th value on the horizontal (x) axis.

Please let me know if this helps you.

UPDATE

In newer versions of the library above 2.0.0 refer to the wiki for how to change the viewport.

+12


source







All Articles