Hi,
I am using the version 2.1.3 of this library, and I have live data (EMG signal) coming in that I process using LineChart.
The problem is that while trying to "zoomIn" on the most recent values, nothing seems to happen.
I have a dataset at any given point of 2K points (as given by getXValCount()), but if I do:
setVisibleXRangeMaximum(20), all of the points seem to show, and not only the latest 20 entries. If the purpose of this function different? What changes should I make?
I am also interested in this feature. I want to show only 10 bars in BarChart using
barChart.setVisibleXRangeMaximum(10). But, interestingly, it shows all the bars.
I just found out, ordering matters for this to work. You need to call setVisibleXRangeMaximum after you invalidate or notifyDataSetChanged
@broncha Your solution seems to work, but the bar chart shows the first n entries, not the latest. That is scroll starts from left to right. How can we get it display data so that the latest n entries visible first and the scroll is from right to left.
moveViewTo(...) is what you are looking for. It's all in the documentation: https://github.com/PhilJay/MPAndroidChart/wiki/Modifying-the-Viewport
In my case it helped me chart.fitScreen() before chart.setVisibleXRangeMaximum(variable);
Most helpful comment
I just found out, ordering matters for this to work. You need to call
setVisibleXRangeMaximumafter youinvalidateornotifyDataSetChanged