[英]AnyChart on Android: Format x-Axis values
我目前是第一次在Android上使用AnyChart。 數據顯示正確,到目前為止一切正常。 但是我無法在x軸上設置值的格式。
我嘗試使用
cartesian2.xAxis(0).labels("{%Value}{numDecimals:2}");
但這沒有任何作用。 我只想要兩個十進制數字。 我找不到在線解決方案,因為大多數文檔都是關於JS的。
編輯:
APIlib.getInstance().setActiveAnyChartView(brightplot);
List<DataEntry> brightnessdata = createSeries(maxBrightnessRow);
Cartesian cartesian2 = AnyChart.column();
cartesian2.data(brightnessdata);
cartesian2.title("Intensitätsverteilung");
cartesian2.yScale().minimum(0d);
cartesian2.yScale().maximum(255);
cartesian2.xAxis(0).title("Ort [cm]");
cartesian2.yAxis(0).title("Intensität");
cartesian2.xScroller(true);
cartesian2.xZoom(true);
cartesian2.yAxis(0).labels(false);
cartesian2.xZoom().setToPointsCount(1500,false, null);
cartesian2.xAxis(0).labels().format("{%Value}{decimalsCount:2}");
brightplot.setHorizontalScrollBarEnabled(true);
brightplot.setVerticalScrollBarEnabled(true);
brightplot.setZoomEnabled(true);
brightplot.setChart(cartesian2);
brightplot.setVisibility(View.VISIBLE);
您應該使用format()
函數和格式化參數,它們被定義為其標記。 嘗試以下行:
cartesian2.xAxis(0).labels().format("{%Value}{decimalsCount:2}");
這應該工作!
問題是x值應該具有“數字”類型,因此要使其全部正常工作,請編寫以下行: chart.xAxis().labels().format("{%value}{type:number, decimalsCount:2}");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.