Highcharts Sankey Diagram with hidden nodes

Highcharts

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/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>

<figure class="highcharts-figure">
  <div id="container"></div>
  <p class="highcharts-description">
    Sankey charts are used to visualize data flow and volume
    between nodes. The wider lines indicate larger volumes.
  </p>
</figure>

CSS

#csv {
    display: none;
}

.highcharts-figure,
.highcharts-data-table table {
    min-width: 310px;
    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;
}

JavaScript

Highcharts.chart('container', {
  chart: {
    marginLeft: -100,
    events: {
      load: function() {
        let chart = this,
          graphic = chart.graphic,
          series = chart.series[0],
          nodes = series.nodeLookup,
          columns = series.nodeColumns;

        for (let i in nodes) {
          if (nodes[i].id === "step0") {
            nodes[i].update({
              color: 'transparent'
            });
            nodes[i].graphic.hide();
            nodes[i].dataLabel.hide();
            nodes[i].visible = false;
            nodes[i].linksFrom[0].graphic.hide();
          }
        }
      }
    }
  },

  title: {
    text: 'Highcharts Sankey Diagram with hidden nodes'
  },
  series: [{
    keys: ['from', 'to', 'weight'],
    data: [
      ['step0', 'step1', 100],
      ['step1', 'step2', 50],
      ['step2', 'step3', 30],
      ['step3', 'step4', 10],
      ['step3', 'step5', 5],
      ['step4', 'step5', 7],
      ['step4', 'step6', 0],
      ['step5', 'step6', 0],
    ],
    type: 'sankey',
    name: 'Sankey demo series'
  }]

});