MPAndroidChart如何从大数据集的最后一个x值开始? [英] How can MPAndroidChart begin at the last x-value with a large dataset?
问题描述
我正在使用Android中的 MPAndroidChart 库.
I am using MPAndroidChart library in Android.
我正在尝试让图形从最后一组x值开始.
I'm trying to get the graph to start at the last set of x values.
我想显示直到现在的一年中的每一天,所以1-271(今天是一年中的第271天)
I would like to show every day of the year up until now so 1 - 271 (today is the 271st day of the year)
我正在使用
chart.setVisibleXRangeMaximum(10)
但是图表从显示第1-10天开始,而我想从显示第261-271天开始.
but the chart begins by showing day 1 - 10 and I want to start by showing day 261 - 271.
推荐答案
根据 MPAndroidChart的Wiki ,尝试
chart.moveViewToX(yourNumberOfXPoints);
或chart.moveViewTo(yourNumberOfXPoints);
为什么?
moveViewToX(float xValue):移动当前对象的左侧(边缘) 视口到指定的x值.
moveViewToX(float xValue): Moves the left side (edge) of the current viewport to the specified x-value.
moveViewTo(float xValue,float yValue,AxisDependency轴):这将 将当前视口的左侧移至指定的x值 x轴,并将视口居中到指定的y值 提供的y轴(结合使用setVisibleXRange(...)是有意义的 和setVisibleYRange(...).
moveViewTo(float xValue, float yValue, AxisDependency axis): This will move the left side of the current viewport to the specified x-value on the x-axis, and center the viewport to the specified y-value on the provided y-axis (makes sense in combination with setVisibleXRange(...) and setVisibleYRange(...).
这篇关于MPAndroidChart如何从大数据集的最后一个x值开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!