Javascript examples for Google Chart:Org Chart
Google OrgChart Visualization
<html> <head> <title>Org Chart Example</title> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1','packages':['orgchart']}]}"></script> <div id="chart_div" "></div> <script type="text/javascript"> google.setOnLoadCallback(drawChart); function drawChart() {//from w w w . j ava2s . c o m 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', ''], ['Bob', 'Jim', 'Bob Sponge'], ['Carol', 'Bob', ''] ]); var chart = new google.visualization.OrgChart(document.getElementById('chart_div')); var deph = {}; google.visualization.events.addListener(chart, 'ready', function () { for (var i = 0; i < data.getNumberOfRows(); i++) { deph[i] = 0; } for (var i = 0; i < data.getNumberOfRows(); i++) { var childs = chart.getChildrenIndexes(i); for (var child = 0; child < childs.length; child++) { deph[childs[child]] += deph[i] + 1; } } console.log(deph) }); google.visualization.events.addListener(chart, 'select', function () { if (chart.getSelection().length > 0) { var node_row = chart.getSelection()[0].row; console.log(deph[node_row]) } }) chart.draw(data, { allowHtml: true }); } </script> </body> </html>