添加百分号的最佳方法是什么?
这可以使用:
tooltip : {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
}
但是当有多个类别和值或数量变化时,这很烦人。
添加百分号的最佳方法是什么?
这可以使用:
tooltip : {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
}
但是当有多个类别和值或数量变化时,这很烦人。
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 打印对象,其余的应该很简单。