I have the following EChart in my Angular application:
var option = {
xAxis: {
type: 'category',
data: ["A", "B", "C", "D", "E"]
},
yAxis: {
type: 'value',
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
formatter: (params) => {
return (
"Text One" +
'<br/>' +
params[0].name
);
},
},
series: [
{
data: [1, 2, 3, 4, 5],
name: 'value',
stack: 'one',
type: 'bar',
tooltip: {
formatter: (params) => {
return (
"Text One" +
'<br/>' +
params[0].name
);
},
},
},
{
data: [0, 1, 2, 3, 4],
name: 'prediction',
stack: 'one',
type: 'bar',
tooltip: {
formatter: (params) => {
return (
"Text Two" +
'<br/>' +
params[0].name
);
},
},
},
],
};
I basically have two series and my question is how I can format the tooltip for each series specifically.
In my example only "Text 1" is shown from the first series.
There are two types of tooltip trigger ('item' and 'axis')
Please use tooltip.trigger = 'item', to display tooltip individually for different series.
tooltip.trigger='axis' is used to display a common tooltip with all series data at a given axis level.