Organization chart
author(s): Torstein Hønsi
by Black Label
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/sankey.js"></script>
<script src="https://code.highcharts.com/modules/organization.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<figure class="highcharts-figure">
<div id="container"></div>
<p class="highcharts-description">
Organization charts are a common case of hierarchical network charts,
where the parent/child relationships between nodes are visualized.
Highcharts includes a dedicated organization chart type that streamlines
the process of creating these types of visualizations.
</p>
</figure>
CSS
.highcharts-figure,
.highcharts-data-table table {
min-width: 360px;
max-width: 800px;
margin: 1em auto;
}
.highcharts-data-table table {
font-family: Verdana, sans-serif;
border-collapse: collapse;
border: 1px solid #ebebeb;
margin: 10px auto;
text-align: center;
width: 100%;
max-width: 500px;
}
.highcharts-data-table caption {
padding: 1em 0;
font-size: 1.2em;
color: #555;
}
.highcharts-data-table th {
font-weight: 600;
padding: 0.5em;
}
.highcharts-data-table td,
.highcharts-data-table th,
.highcharts-data-table caption {
padding: 0.5em;
}
.highcharts-data-table thead tr,
.highcharts-data-table tr:nth-child(even) {
background: #f8f8f8;
}
.highcharts-data-table tr:hover {
background: #f1f7ff;
}
#container h4 {
text-transform: none;
font-size: 14px;
font-weight: normal;
}
#container p {
font-size: 13px;
line-height: 16px;
}
@media screen and (max-width: 600px) {
#container h4 {
font-size: 2.3vw;
line-height: 3vw;
}
#container p {
font-size: 2.3vw;
line-height: 3vw;
}
}
JavaScript
var protoSetState = Highcharts.Point.prototype.setState;
Highcharts.wrap(Highcharts.seriesTypes.organization.prototype, 'pointAttribs', function(p, point, state) {
var attrs = p.apply(this, Array.prototype.slice.call(arguments, 1));
if (state === 'inactive') {
attrs.opacity = 0.2;
} else {
attrs.opacity = 1;
}
return attrs;
});
Highcharts.seriesTypes.organization.prototype.pointClass.prototype.setState = function(state) {
var args = arguments;
// Propagate state to children:
setChildrenState(this.isNode ? this : this.fromNode);
// Uncomment below to show parents too:
setParentState(this.isNode ? this : this.toNode);
function setChildrenState(node) {
node.linksFrom.forEach(function(link) {
if (link.toNode) {
setChildrenState(link.toNode);
}
});
protoSetState.apply(node, args);
}
function setParentState(node) {
node.linksTo.forEach(function(link) {
if (link.fromNode) {
setParentState(link.fromNode);
}
});
protoSetState.apply(node, args);
}
};
Highcharts.chart('container', {
chart: {
height: 600,
inverted: true
},
title: {
text: 'Highcharts Org Chart'
},
accessibility: {
point: {
descriptionFormatter: function (point) {
var nodeName = point.toNode.name,
nodeId = point.toNode.id,
nodeDesc = nodeName === nodeId ? nodeName : nodeName + ', ' + nodeId,
parentDesc = point.fromNode.id;
return point.index + '. ' + nodeDesc + ', reports to ' + parentDesc + '.';
}
}
},
series: [{
type: 'organization',
name: 'Highsoft',
keys: ['from', 'to'],
data: [
['Shareholders', 'Board'],
['Board', 'CEO'],
['CEO', 'CTO'],
['CEO', 'CPO'],
['CEO', 'CSO'],
['CEO', 'HR'],
['CTO',...