我使用VChart图表时,发现如果数字的小数位比较长时显示效果很不美观,有什么办法能控制标签显示的小数位长度吗?
我使用VChart图表时,发现如果数字的小数位比较长时显示效果很不美观,有什么办法能控制标签显示的小数位长度吗?
通过VChart的标签格式化函数可以解决这个问题,此外格式函数还可以支持自定义数字单位等需求
// two decimal places
spec.label.formatMethod = (value: number) => (+value).toFixed(2)
// numerical unit
spec.label.formatMethod = (value: number) => ((+value)/1e3).toFixed(2) + 'k'
Demo: https://codesandbox.io/s/label-formatter-d34xrm?file=/src/ind...
formatMethod option:https://visactor.bytedance.net/vchart/option/barChart#label.f...
label tutorials: https://visactor.bytedance.net/vchart/guide/tutorial_docs/Cha...
10 回答11.3k 阅读
5 回答4.9k 阅读✓ 已解决
4 回答3.2k 阅读✓ 已解决
2 回答2.8k 阅读✓ 已解决
3 回答5.2k 阅读✓ 已解决
1 回答3.4k 阅读✓ 已解决
3 回答2.4k 阅读✓ 已解决
使用formatter属性来调整标签显示的格式
参考文档 https://echarts.apache.org/zh/option.html#series-line.label.f...