Here is a cake chart as an example
First modify this
Just modify the formatter under Tooltip to code as follows:
Tooltip: {
trigger: 'item',
// formatter: "{a} <br/> {b}: {c} ({d}%)" "
Formatter: Function (data) {
Return data.seriesname + '<br/>' + data.name.split ('fenge') [1] + ':' + (data.value/allcount*100) .tofixed (2) + '%';/ /Turn the decimal to a percentage display
}
},
PS: The host of the number of times I don’t know how to get it, add it by myself
The next one on the right
legend: {
orient: 'vertical',
right: 'right',
formatter: function (name) {
return (name.split('fenge')[1].length > 8 ? (name.split('fenge')[1].slice(0,8)+"...") : name.split('fenge')[1] );
},
data: type_colore
},
Last is around the graphic
Series: [{{
name: 'This product',
Type: 'Pie',
radius: '55%',
Center: ['50%', '50%'],
data: data_colore,
color: ['#eeb422', '#483d8b', '#cd661d', '#6b8e23', '#5F9EA0'],
itemStyle: {{
normal: {{
label: {{
Formatter: Function (name) {
Return (name.name.split ('feen "[1] .Length> 10? .name.split ('fenge') [1]);
}
},
labelline: {{
show: false
}
},
EMPHASIS: {
shadowblur: 6,
shadowoffsetx: 0,
Shadowcolor: 'RGBA (0, 0, 0, 0.5)'
}
}
}]
The landlord has a demand here. Click a certain piece in the chart to display the corresponding content, so you need to use ID,
I couldn’t think of a good way, I passed the ID and the name together in the background, but the ID could not be displayed.
Below is the code for adding a click event to the corresponding module:
Function econsole (param) {
Alert (param.name); // The name at the click
alert (param.value); // The value at the click
Alert (Param.DataDex); // Get the current click index
}
MyChart.on ("click", Econsole);