Due to the use of echarts in the recent work content, the implementation of product design drawings encountered a number of small problems, such as:
The design diagram is like this:
And Echarts's legend legend is probably like this (note: The following demo are readily written):
See Echarts Dynamic Data thought of course is formatter, then think of course is tooltip in formatter, ToolTip is the mouse hover chart item of that translucent small box, probably long like this:
The code chief is like this (since we can come here, we all know):
ToolTip: {
trigger: ' Item ',
formatter: ' {A} <br/>{b}: {C} ({d}%) '
},
The thought is a,b,c,d four parameters are echarts ready to use directly, the result becomes this:
"Nick Yang question mark face" WTF.
Put the formatter in the ToolTip in the legend the road does not work, check the document did not see the relevant methods, the Internet to see what seems to say is what function can. Such as:
Formatter:function (params) {
//do some thing
}
Also thought that this params is an object what, inside has the attribute of each item, whether can use directly, but this params prints out is a legend the item in the legend, to it carries on the operation does not have what valuable function, Then think of the value to display to formatter and then use, the first thought is to read the series in the data array of object properties, and then traverse assignment to params can.
As follows:
Code:
Formatter:function (params) {
//Console.log (params);
for (var i = 0; i < option.series[0].data.length i++) {
if (option.series[0].data[i].name = = params) {
return params + ":" + option.series[0].data[i].value+ "Up";}}
It is possible, of course, if you have the best solution or there are other better ways to welcome the exchange.