I am trying to use the Google Org Chart control. I would like it to have a single click expand/collapse of nodes (instead of the default double click one) and also provide a
you could use a regular DOM click event,
then check the event target
if an anchor tag (), then follow the address
else expand / collapse
see following working snippet...
google.charts.load('current', {
callback: function () {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Name');
data.addColumn('string', 'Manager');
data.addColumn('string', 'ToolTip');
data.addRows([
[{v:'Mike', f:'Mike'},'', 'The President'],
[{v:'Jim', f:'Jim'},'Mike', 'VP'],
['Alice', 'Mike', ''],
['Bob', 'Alice', ''],
[{v:'John', f:'John'},'Bob', 'VP'],
['Carol', 'Bob', ''],
[{v:'Jake', f:'Jake'},'John', 'VP']
]);
var container = document.getElementById('chart_div');
var chart = new google.visualization.OrgChart(container);
container.addEventListener('click', function (e) {
e.preventDefault();
if (e.target.tagName.toUpperCase() === 'A') {
console.log(e.target.href);
// window.open(e.target.href, '_blank');
// or
// location.href = e.target.href;
} else {
var selection = chart.getSelection();
if (selection.length > 0) {
var row = selection[0].row;
var collapse = (chart.getCollapsedNodes().indexOf(row) == -1);
chart.collapse(row, collapse);
}
}
chart.setSelection([]);
return false;
}, false);
chart.draw(data, {allowHtml:true, allowCollapse:true});
},
packages: ['orgchart']
});