Custom configuration of formatter for tooltip of echarts

default
tooltip: {

in pie chart
                                    trigger: "item",
                                   formatter: "{a} <br/>{b}:{c} ({d}%)",
                                },
                                series

if you change it to

with parameters
                                     // formatter:function(parmas){
                                    // console.log(parmas);
                                    // }

the parmas in this contains only value and name, in series. How do you write it in formatter if you want to load the data returned by ajax?

Mar.24,2021

change the way of thinking. In fact, when ajax updates the chart data, it updates the contents of trigger at the same time.
then you only need to configure tooltip in the success of ajax.
put the formatting operation in success, which can be highly customized and configure the generated results directly to the chart. Or pass it to formatter for the next step.


I don't know why you want to put the acquired data in formatter.


there is a method that has been used in the project, some low, can refer to:
save the value returned by ajax as a variable A; then traverse An according to a value that params gets, and get other values in A. Because the value or name in series must have been obtained from A. If your value and name are duplicated, you can manually map control to ensure that each item in variable An is not repeated.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b330a3-2be7b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b330a3-2be7b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?