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.

Menu