1
我有一些條目的0值,但在我的YAxis這是代表「-0」值。 我該如何避免或排除這種情況?MPAndroidChart - 我如何避免「-0」值表示
我有一些條目的0值,但在我的YAxis這是代表「-0」值。 我該如何避免或排除這種情況?MPAndroidChart - 我如何避免「-0」值表示
使用YAxisValueFormatter
,格式化一切通過使用YAxisValueFormatter的Math.abs(...)
文檔是> = 0至陽性。
private class AxisValueFormatter implements YAxisValueFormatter{
private DecimalFormat mFormat;
public AxisValueFormatter() {
mFormat = new DecimalFormat("###,###,##0.0");
}
@Override
public String getFormattedValue(float value, YAxis yAxis) {
if(Float.compare(-0.0f, value) == 0){
value = Math.abs(value);
}
return mFormat.format(value);
}
}
這不能避免-0,當我放大圖表。你有什麼主意嗎? – rguerra
您使用哪種類型的圖表? – pkBhati
類型爲折線圖 – rguerra
YAxis leftAxis = chart.getAxisLeft(); leftAxis.setStartAtZero(true) – pkBhati