添加百分号的最佳方式是什么?
这可以使用:
tooltip : {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
}
但是当有多个类别和价值或数量不同时,这非常令人讨厌。
答案 0 :(得分:1)
tooltip.formatter
也可以是一个功能。
使用此功能,您可以完全控制应该显示的内容。
示例:
function __handleTooltip(seriesConfiguration) {
// Your code here
// return undefined, if you don't want to show a tooltip
// return a string, if you want to show a tooltip
}
seriesConfiguration
看起来有点像:
// This is a SCATTER-Entry
// But line/bar is just similar, it just has different "data" and "value".
{
"componentType": "series",
"componentSubType": "scatter",
"seriesType": "scatter",
"seriesIndex": 0,
"seriesName": "Daten",
"name": "",
"dataIndex": 9,
"data": [
748,
2206,
2954,
"999999999",
"Some other Value",
""
],
"value": [
748,
2206,
2954,
"999999999",
"Some other Value",
""
],
"color": "rgba(79,142,206,1)",
"$vars": [
"seriesName",
"name",
"value"
]
}
只需使用console.log打印对象,其余部分应该很简单。