I'm creating an org chart using google's code
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Name');
data.addColumn('string', 'Manager');
data.addColumn('string', 'ToolTip');
data.addRows([
[{v:'Mike', f:'Mike<div style="color:red; font-style:italic">President</div>'}, '', 'The President'],
[{v:'Jim', f:'Jim<div style="color:red; font-style:italic">Vice President</div>'}, 'Mike', 'VP'],
['Alice', 'Mike', ''],
['Alice2', 'Mike', ''],
['Alice3', 'Mike', ''],
// ['Alice4', 'Alice3', ''],
// ['Alice5', 'Alice3', ''],
// ['Alice6', 'Alice3', ''],
// ['Alice7', 'Alice3', ''],
// ['Alice8', 'Alice3', ''],
// ['Alice9', 'Alice3', ''],
['Bob', 'Jim', 'Bob Sponge'],
['Carol', 'Bob', '']
]);
var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
chart.draw(data, {allowHtml:true, allowCollapse:true});
}
I want the space between nodes to be adjusted dynamically when they are collapsed, and not set to a pre-computed distance based on number of child nodes. To illustrate, I created 2 hierarchies in jsfiddle
- https://jsfiddle.net/s3azv8pf/1/ - When I collapse 'Alice3' node, I want it to look like below
- https://jsfiddle.net/mv77qrms/1/
In other words, when a node is collapsed, I want it to be displayed as if it had no children. Only when I expand the node, it should slide to the right and take up more space, similar to Mike Bostock's collapsible reingold tree