Hi Farlley, Thank you for using Apache ECharts. Although not documented, the click on the tree series will trigger the 'treeExpandAndCollapse' event. You might try listening with chart.on('treeExpandAndCollapse', params => console.log(params)) to capture the click event. Then, in the callback function, you can call chart.dispatchAction({ type: 'treeExpandAndCollapse', seriesId: 0, dataIndex: calculatedSiblingId }). Since dataIndex does not support arrays, this can only close one node. You may need to call this method multiple times.
I'm not certain whether this solution will work. If it doesn't, perhaps you could consider submitting a PR to support the array form. Thanks *Ovilia* On Thu, May 15, 2025 at 12:29 AM Farlley Tesch (Datasource Expert) <farlley@datasource.expert> wrote: > Hello ECharts team, > > We are currently using the ECharts tree chart component to visualize > hierarchical data in a solution being developed for a major Oil & Gas > company in Brazil. > > One specific behavior requested by our client is the ability to > **automatically collapse sibling nodes when a node is expanded**. The idea > is that when a user opens a node, all other nodes at the same level should > collapse, showing only the branch of the node that was clicked. This helps > reduce visual clutter and allows for a more focused user experience, > especially in large tree structures. > > This feature is of high importance because the tool is already being used > by key stakeholders, including board-level executives and investors. > > We reviewed the documentation and examples (e.g., [ > https://echarts.apache.org/examples/en/editor.html?c=tree-basic](https://echarts.apache.org/examples/en/editor.html?c=tree-basic)) > but did not find a built-in option or recommended workaround to achieve > this behavior. > > Would it be possible to support this functionality in future versions of > ECharts? Or is there a recommended approach to implement this behavior > using current APIs? > > Thank you very much for your excellent work on this project. We look > forward to hearing your thoughts. > > Best regards, > > > *Farlley Tesch* > *Product Manager* > *farlley@datasource.expert* > +55 (27) 98851-5951| (27) 3015-1800 > Site: https://www.datasource.expert/ > *Blog*: https://blogs.datasource.expert/ > *Conheça o DEXBoard:* https://dexboard.datasource.expert/ > >