This demo shows how we can use setting-bound event to limit open branches in ForceDirectedSeries
to one.
The following code ensures that all open branches are collapsed, when another branch is expanded.
series.nodes.template.on("disabled", function(disabled, targetNode) { let targetLevel = targetNode.dataItem.get("depth"); if (!disabled) { series.nodes.each(function(node) { if (node.dataItem.get("depth") == targetLevel && node !== targetNode) { node.set("disabled", true); } }) } })
series.nodes.template.on("disabled", function(disabled, targetNode) { var targetLevel = targetNode.dataItem.get("depth"); if (!disabled) { series.nodes.each(function(node) { if (node.dataItem.get("depth") == targetLevel && node !== targetNode) { node.set("disabled", true); } }) } })
See the Pen amCharts 5: Limit to single open branch in ForceDirectedSeries by amCharts team (@amcharts) on CodePen.