在 MPAndroidChart 中用 B(billion) 或 M(million) 显示 y 轴值
Display y axis value with B(billion) or M(million) in MPAndroidChart
我在 Y 轴上有一些值(看图片)!我希望他们像 100M, 200M,...
我正在使用 MPAndroidchart。有什么解决办法吗?
您可以通过 AxisValueFormatter . You can write your own pretty easily if you need to, but MPAndroidChart already comes with a LargeValueFormatter 实现您所描述的功能。
来自 AxisValueFormatter help page 关于预定义格式化程序的部分:
LargeValueFormatter: Can be used for formatting large values >
"1,000". It will turn values like "1,000" into "1k", "1,000,000" will
be "1m" (million), "1,000,000,000" will be "1b" (billion) and values
like one trillion will be e.g. "1t".
使用示例:
YAxis left = chart.getAxisLeft();
left.setValueFormatter(new LargeValueFormatter());
我在 Y 轴上有一些值(看图片)!我希望他们像 100M, 200M,...
我正在使用 MPAndroidchart。有什么解决办法吗?
您可以通过 AxisValueFormatter . You can write your own pretty easily if you need to, but MPAndroidChart already comes with a LargeValueFormatter 实现您所描述的功能。
来自 AxisValueFormatter help page 关于预定义格式化程序的部分:
LargeValueFormatter: Can be used for formatting large values > "1,000". It will turn values like "1,000" into "1k", "1,000,000" will be "1m" (million), "1,000,000,000" will be "1b" (billion) and values like one trillion will be e.g. "1t".
使用示例:
YAxis left = chart.getAxisLeft();
left.setValueFormatter(new LargeValueFormatter());