Den*_*nis 23 android mpandroidchart
2关于MPAndroidChart库的问题.我的所有yvalues都是整数,但显示为Decimals.如何将它们显示为整数(没有数字)?如何防止ylabels也显示为小数?我知道yvalues有一个setFormatter,只是不明白如何使用...
Phi*_*oda 36
看看库提供的IValueFormatter
界面.使用该界面,您可以根据自己的逻辑完全自定义图表上显示的内容.
用法:
chart.setValueFormatter(new YourValueFormatter());
YLabels yl = chart.getYLabels();
yl.setFormatter(new YourValueFormatter());
Run Code Online (Sandbox Code Playgroud)
更新(对于此库的2.0.0+版本):
现在,ValueFormatter
可以为每个DataSet
单独设置一个,或者ValueFormatter
可以为整个数据对象包含所有设置相同DataSets
.此外,YLabels
现在调用该类YAxis
.
例:
// set for whole data object (individual DataSets also possible)
LineData data = new LineData(...);
data.setValueFormatter(new YourValueFormatter());
// YLabels are now called YAxis
YAxis yAxis = mChart.getAxisLeft(); // get the left or right axis
yAxis.setValueFormatter(new YourAxisValueFormatter());
Run Code Online (Sandbox Code Playgroud)
更新(对于此库的3.0.0+版本):
格式化界面已在其功能中重命名和扩展.现在,IAxisValueFormatter
可以用来格式化两者的价值观XAxis
和YAxis
.该IValueFormatter
界面用于自定义图表值.
归档时间: |
|
查看次数: |
24051 次 |
最近记录: |