Reputation: 5535
What is the best way to add percent sign?
This could be doable using:
tooltip : {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
}
But that is quite annoying when there are multiple categories and values or when the number varies.
Upvotes: 1
Views: 3417
Reputation: 1639
tooltip.formatter
also can be a function.
Using this, you have full control what and if it should be displayed.
Example:
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
looks somewhat like that:
// 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"
]
}
Just use console.log to print the object, the rest should be straightforward.
Upvotes: 1