2017-04-09 119 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

相關問題