2017-04-09 75 views
0

设定x轴标签我显示实时图表,其应该显示的值作为每秒。我的X轴是时间秒。但我无法在x轴上显示固定的时间间隔,即。 0,1,2,...等等。自动计算X轴值,两个x值之间的时间间隔变为20秒,这是我不想要的。我需要你的帮助来解决这个问题。MPAndroidChart:如何在固定的时间间隔

任何帮助将不胜感激。

+1

尝试此解决方案:http://stackoverflow.com/a/40806503/1343788 –

+0

间隔称为“粒度”。你可以试试'mChart.getXAxis()setGranularityEnabled(真)''mChart.getXAxis()setGranularity(desiredGranularity)'。 –

回答

1

您可以使用,可以让用户知道哪些标签应当在绘制图形库的修改版本。

请参见下面的例子:

leftAxis.setShowSpecificLabelPositions(true); 
leftAxis.setSpecificLabelPositions(new float[]{0, 10, 20, 50, 100, 300}); 

参考链接:https://github.com/PhilJay/MPAndroidChart/pull/2692

修改的库链接:https://github.com/philippeauriach/MPAndroidChart/tree/custom-labels

+0

setShowSpecificLabelPositions()和setSpecificLabelPositions()未找到 – theLazyFinder

+0

@theLazyFinder你必须使用库的修改版本; https://github.com/philippeauriach/MPAndroidChart/tree/custom-labels – fgueli

相关问题