apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.19k stars 19.61k forks source link

[Bug] Sunburst diagram resets to the root view if data is updated #19601

Open big-r81 opened 7 months ago

big-r81 commented 7 months ago

Version

5.4

Link to Minimal Reproduction

https://jsfiddle.net/eLojgs21/

Steps to Reproduce

  1. Click on a (sub-) segment in the sunburst chart, e.g. "Uncle Leo"
  2. select a category in the legend

Current Behavior

If zoomed into a sunburst diagram and selecting a category, the (root) view is resetted and gets zoomed to the root level.

Expected Behavior

This behavior is triggered, through setting new data with the setOption function. Afterwards the function optionUpdated is triggered and resets the root view of the component.

I don't know if it's really a bug and/or a feature request, but it should be possible to update the data and don't change the actual view of the diagram. Maybe there is a workaroudn for this, which I don't know.

Environment

- OS: Windows
- Browser: Chrome 120.0.6099.71
- Framework: -

Any additional comments?

Is there a way to show the updated data without the reset of the view?

MatthiasMert commented 7 months ago

Maybe a good solution would be to add a new feature initialRootNode which allows to specify the initial view of the sunburst diagram (somewaht similar to initialTreeDepth ). This way setOption could be triggered and used to restore the previous view of the sunburst chart.

big-r81 commented 1 month ago

@MatthiasMert

I played around with the source code and experimented a little bit. The repainting of the view is done by calling this function. Then the view is resetted and repainted. I also found this function call as an option, which is apparently used when you click on an element in the sunburst diagram.

Do you have any idea how this can be used to prevent a complete reset to the root node?