如何为 MPAndroidChart 中的每个 y 值设置 x 轴标签?
How to set x-axis label for every y-value in MPAndroidChart?
我想为折线图中的每个 y 值在 x 轴上设置一个标签。我想得到这个结果:
有人可以帮我在 MPAndroidChart 中找到正确的方法吗?
您可能正在寻找粒度 - 请参阅the wiki page for the axis and the javadoc。
这样调用:
mChart.getXAxis().setGranularity(0.3f);
mChart.getXAxis().setGranularityEnabled(true);
将确保 0.3
是放大时轴上的最小间隔。除此之外,您可能需要通过调用来调整 x 轴的比例:
mChart.getXAxis().setAxisMinValue(10.01f); //experiment with these values
mChart.getXAxis().setAxisMaxValue(10.14f);
mChart.getXAxis().setLabelCount(5);
我想为折线图中的每个 y 值在 x 轴上设置一个标签。我想得到这个结果:
有人可以帮我在 MPAndroidChart 中找到正确的方法吗?
您可能正在寻找粒度 - 请参阅the wiki page for the axis and the javadoc。
这样调用:
mChart.getXAxis().setGranularity(0.3f);
mChart.getXAxis().setGranularityEnabled(true);
将确保 0.3
是放大时轴上的最小间隔。除此之外,您可能需要通过调用来调整 x 轴的比例:
mChart.getXAxis().setAxisMinValue(10.01f); //experiment with these values
mChart.getXAxis().setAxisMaxValue(10.14f);
mChart.getXAxis().setLabelCount(5);