我實際上並沒有用AChartEngine做過很多事情,但快速瀏覽一下源代碼後發現,你可以擴展BarChart
來完成你以後的工作。
看一看位於AbstractChart
的getLabel(double label)
方法(BarChart
延伸XYChart
,其在它的轉延伸AbstractChart
)。
/**
* Makes sure the fraction digit is not displayed, if not needed.
*
* @param label the input label value
* @return the label without the useless fraction digit
*/
protected String getLabel(double label) {
String text = "";
if (label == Math.round(label)) {
text = Math.round(label) + "";
} else {
text = label + "";
}
return text;
}
我會從一些天真的東西開始,看看它是如何工作的;例如只需在上面的結果追加"%"
:
@Override protected String getLabel(double label) {
return super.getLabel(label) + "%";
}
我不是太肯定的是同樣的方法是否被用於生成X軸標籤的唯一的事情。如果是這樣的話,你可能需要做一些稍微聰明,使之只爲你感興趣的軸。