undefinedfix
Sign in

Can I change the tree diagram in ecarts to a different picture?

Yashu edited in Sun, 14 Aug 2022

Here's a tree: I want to change the circle to the user's Avatar,

I looked at the ecarts document, https://www.echartsjs.com/opt... It is said that:

If the graph of each data is different, it can be set as a callback function in the following format: (value: array | number, params: object) = > number | array, where the first parameter value is the data value in data. The second parameter params is the other data item parameters.

So I put symbol : ' emptyCircle ' Change to:

symbol: function (value, params) {
    console.log('symbol callback:', value, params);
    return 'emptyCircle';
},

In principle, as long as the callback function is executed, the console will have output. But it didn't, but it output an error:

clipboard.png

Is this a bug in ecarts? Or is there something wrong with my writing?

2 Replies
M_Salehi
commented on Sun, 14 Aug 2022

This is strange. I read the source code, because the function is passed in, so the index of reports an error. It is suggested that the original data can be modified directly

data.symbol = 'triangle'
   data.children.map((item) => {
            item.symbol = 'circle'
     
      if (item.children) { 
        item.children.map(i => { 
          i.symbol = 'circle' 
        })
      }
      })
When data is transferred in the background, you can directly transfer this parameter and put it on your avatar, so you don't have to deal with it yourself
bakapasanac
commented on Mon, 15 Aug 2022

But the official documents support the writing of functions

If the graph of each data is different, it can be set as a callback function in the following format:

(value: Array|number, params: Object) => string 

The first parameter value is the data value in data. The second parameter params is the other data item parameters.

The actual use will report an error

lock This question has been locked and the reply function has been disabled.