phatlewt commented on issue #14539:
URL: https://github.com/apache/echarts/issues/14539#issuecomment-1114061187
Technically i think it's the correct functionality- the center of a sunburst
chart is always considered the "root" so it should always show the root or the
top level of the data hierarchy.
I was also facing the same problem so I clicked around the browser inspector
of the echarts object and I think I found a solution, which is to get the chart
model's series viewRoot:
let viewRoot = myChart._model.getSeries()[0]._viewRoot;
console.log(viewRoot);
of interest are these properties: name (name of current node), depth (depth
of tree; 0=root, 1=1st level, etc.), children[] (array of data objects under
current level).
so within the click handler you can do:
```
myChart.on('click', 'series', (e)=>
{
console.log(e.data);
let viewRoot = myChart._model.getSeries()[0]._viewRoot;
switch(viewRoot.depth)
{
case 0: /*do something for root*/ break;
case 1: /*do something for 1st level*/ break;
..etc..
}
});
```
if you need to get the chart object at some other point in the code:
` echarts.getInstanceByDom(document.getElementById("your chart element
id"))._model.getSeries()[0]._viewRoot`
I've only just discovered this charting library last week so am quite new
and still exploring it too.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]