echarts icon indicating copy to clipboard operation
echarts copied to clipboard

Sunburst series click event sends the wrong data when coming back from multi level drilled down state

Open sameeraroshan opened this issue 4 years ago • 4 comments

Version

5.0.2

Steps to reproduce

Drill down to multiple levels while listing to series click event . myChart.on('click', 'series', (e)=>{ console.log(e.data)}) event always contains the 1st level data when coming back after a drill down state.

What is expected?

correct data for current level should be sent along with the click event

What is actually happening?

chart always sends the 1st level data when coming back


please refer the attached video.

screencast-nimbus-capture-2021 03 26-22_20_51

sameeraroshan avatar Mar 26 '21 18:03 sameeraroshan

Hi! We've received your issue and please be patient to get responded. 🎉 The average response time is expected to be within one day for weekdays.

In the meanwhile, please make sure that you have posted enough image to demo your request. You may also check out the API and chart option to get the answer.

If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to [email protected]. Please attach the issue link if it's a technical question.

If you are interested in the project, you may also subscribe our mailing list.

Have a nice day! 🍵

echarts-bot[bot] avatar Mar 26 '21 18:03 echarts-bot[bot]

Anyone got this solved?

sameeraroshan avatar May 26 '21 06:05 sameeraroshan

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.

phatlewt avatar Apr 30 '22 22:04 phatlewt

This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.

github-actions[bot] avatar Apr 30 '24 21:04 github-actions[bot]

This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!

github-actions[bot] avatar May 08 '24 21:05 github-actions[bot]