如何在MPAndroidChart中连续更新Y轴值 [英] How to continuously update Y-axis values in MPAndroidChart
问题描述
我希望LineChart中的轴实时调整其最大值和最小值.当新数据的Y值增加(正值和负值)时,如resetAxisMaxValue()和resetAxisMinValue()之类的功能可以很好地工作,但是,一旦信号再次变低,Y值的最大值和最小值就永远不会下降到较小的值,因此它可以显示图整个画布上的所有新数据.我想检查是否有自动执行此操作的方法,或者是否应该使用蛮力.谢谢.
I want my axis in LineChart to adjust it's maximum and minimum values real-time. Functions like resetAxisMaxValue() and resetAxisMinValue() work well when new data's Y-value is increasing(both positive and negative), however, once the signal gets low again Y-value max and min never drops to the smaller values so it can show all new data on the full canvas of the graph. I wanted to check whether there is method to do so automatically, or whether I should use brute force. Thank you.
推荐答案
Alex的回答有点老了,所以...
Alex's answer is a bit old, so...
MPAndroidChart有一个名为 setAutoScaleMinMaxEnabled(boolean enabled)
的方法.它使您的图表可以自动调整图表的比例.您可以像这样简单地使用它.
MPAndroidChart has a method called setAutoScaleMinMaxEnabled(boolean enabled)
.
It enables your chart to automatically adjusts the chart's scale. You could use it simply like this.
chart.setAutoScaleMinMaxEnabled(true);
这篇关于如何在MPAndroidChart中连续更新Y轴值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!