On the method of implementing Dynamic Data in Echarts formatter data visualization

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.