An organizational chart that supports selection.
By: Google
Code it yourself on the Visualization Playground
<html>
<head>
<script type='text/javascript' src='http://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {packages:['orgchart']});
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', ''],
['Bob', 'Jim', 'Bob Sponge'],
['Carol', 'Bob', '']
]);
var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
chart.draw(data, {allowHtml:true});
}
</script>
</head>
<body>
<div id='chart_div'></div>
</body>
</html>
The google.load package name is 'orgchart'
google.load('visualization', '1', {packages: ['orgchart']});
The visualization's class name is google.visualization.OrgChart
var visualization = new google.visualization.OrgChart(container);
A table with three string string columns, where each row represents a node in the orgchart. Here are the three columns:
Each node can have zero or one parent node, and zero or more child nodes.
You can assign the following custom properties to data table elements, using the setProperty() method
of DataTable:
| Property Name | Applies To | Description |
|---|---|---|
| selectedStyle | DataTable row | An inline style string to assign to a specific node when selected.
You must set the option Example: |
| style | DataTable row | An inline style string to assign to a specific node. This is overridden
by the Example: |
| Name | Type | Default | Description |
|---|---|---|---|
| allowCollapse | boolean | false | Determines if double click will collapse a node. |
| allowHtml | boolean | false | If set to true, names that includes HTML tags will be rendered as HTML. |
| color | string | '#edf7ff' | Deprecated. Use nodeClass instead. The background color of the orgchart elements. |
| nodeClass | string | default class name | A class name to assign to node elements. Apply CSS to this class name to specify colors or styles for the chart elements. |
| selectedNodeClass | string | default class name | A class name to assign to selected node elements. Apply CSS to this class name to specify colors or styles for selected chart elements. |
| selectionColor | string | '#d6e9f8' | Deprecated. Use selectedNodeClass instead. The background color of selected orgchart elements. |
| size | string | 'medium' | 'small', 'medium' or 'large' |
| Method | Return Type | Description |
|---|---|---|
collapse(row, collapsed) |
none | Collapses or expands the node.
|
draw(data, options) |
none | Draws the chart. |
getChildrenIndexes(row) |
Array.<number> |
Returns an array with the indexes of the children of the given node. |
getCollapsedNodes |
Array.<number> |
Returns an array with the list of the collapsed node's indexes. |
getSelection() |
Array of selection elements | Standard getSelection() implementation. Selection elements are all row
elements. Can return more than one selected row. |
setSelection(selection) |
none | Standard setSelection() implementation.
Treats every selection entry as a row selection. Supports selection of
mutiple rows. |
| Name | Description | Properties |
|---|---|---|
| collapse | Event triggered when allowCollapse is set to true and
the user double clicks on a node with children. |
|
| onmouseover | Triggered when the user hovers over a specific row. | row - The zero-based index of the row in the data table,
corresponding to the node being moused over. |
| onmouseout | Triggered when the user hovers out of a row. | row - The zero-based index of the row in the data table,
corresponding to the node being moused out from. |
| select | Standard select event | None |
| ready | The chart is ready for external method calls. If you want to interact
with the chart, and call methods after you draw it, you should set up a
listener for this event before you call the draw method,
and call the methods only after the event is fired. |
None |
All code and data are processed and rendered in the browser. No data is sent to any server.