Highchart organization chart: Hide show child nodes on parent click
HTML
<!-- Load the Highcharts scripts. Please note that
Highcharts GPT loads all scripts because we do not know what is being used
in the configuration previews. In production, unused scripts should be removed. -->
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/highcharts-3d.js"></script>
<script src="https://code.highcharts.com/modules/stock.js"></script>
<script src="https://code.highcharts.com/maps/modules/map.js"></script>
<script src="https://code.highcharts.com/modules/gantt.js"></script>
<script src="https://code.highcharts.com/dashboards/datagrid.js"></script>
<script src="https://code.highcharts.com/dashboards/dashboards.js"></script>
<script src="https://code.highcharts.com/dashboards/modules/layout.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/parallel-coordinates.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<script src="https://code.highcharts.com/modules/annotations-advanced.js"></script>
<script src="https://code.highcharts.com/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/draggable-points.js"></script>
<script src="https://code.highcharts.com/modules/static-scale.js"></script>
<script src="https://code.highcharts.com/modules/broken-axis.js"></script>
<script src="https://code.highcharts.com/modules/heatmap.js"></script>
<script src="https://code.highcharts.com/modules/tilemap.js"></script>
<script src="https://code.highcharts.com/modules/timeline.js"></script>
<script src="https://code.highcharts.com/modules/treemap.js"></script>
<script src="https://code.highcharts.com/modules/treegraph.js"></script>
<script src="https://code.highcharts.com/modules/item-series.js"></script>
<script src="https://code.highcharts.com/modules/drilldown.js"></script>
<script...
JavaScript
Highcharts.chart("container", {
chart: {
type: "organization",
height: 900,
inverted: false,
layoutBy: "hanging",
},
title: {
text: "Toggle Child Node Visibility on Parent Node Click",
},
series: [
{
keys: ["from", "to"],
data: [
["CEO", "CTO"],
["CEO", "CFO"],
["CTO", "Dev1"],
["CTO", "Dev2"],
["CFO", "Accountant1"],
["CFO", "Accountant2"],
["CFO", "Accountant3"],
["CFO", "Accountant4"],
],
nodes: [
{
id: "CEO",
title: "Chief Executive Officer",
},
{
id: "CTO",
title: "Chief Technology Officer",
visible: true,
},
{
id: "CFO",
title: "Chief Financial Officer",
},
{
id: "Dev1",
title: "Developer 1",
},
{
id: "Dev2",
title: "Developer 2",
},
{
id: "Accountant1",
title: "Accountant 1",
},
{
id: "Accountant2",
title: "Accountant 2",
},
{
id: "Accountant3",
title: "Accountant 2",
},
{
id: "Accountant4",
title: "Accountant 2",
},
{
id: "Accountant5",
title: "Accountant 2",
},
{
id: "Accountant6",
title: "Accountant 2",
},
{
id: "Accountant7",
title: "Accountant 2",
},
{
id: "Accountant8",
title: "Accountant 2",
},
{
id: "Accountant9",
title: "Accountant 2",
},
{
id: "Accountant10",
title: "Accountant 2",
},
],
colorByPoint: true,
point: {
events: {
click: function () {
// Build a map of 'from' to 'to' relationships for quick lookups
const hierarchy =...