Highcharts Demo

author(s): Sebastian Bochan

by Black Label

HTML

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/sankey.js"></script>
<div id="container"></div>

JavaScript

const isObject = Highcharts.isObject,
   merge = Highcharts.merge

 function getDLOptions(
   params
 ) {
   const optionsPoint = (
       isObject(params.optionsPoint) ?
       params.optionsPoint.dataLabels : {}
     ),
     optionsLevel = (
       isObject(params.level) ?
       params.level.dataLabels : {}
     ),
     options = merge({
       style: {}
     }, optionsLevel, optionsPoint);
   return options;
 }

 Highcharts.wrap(
   Highcharts.seriesTypes.sankey.prototype,
   'translateNode',
   function(proceed, node, column) {
     var translationFactor = this.translationFactor,
       series = this,
       chart = this.chart,
       options = this.options,
       sum = node.getSum(),
       nodeHeight = Math.max(Math.round(sum * translationFactor),
         this.options.minLinkWidth),
       nodeWidth = Math.round(this.nodeWidth),
       crisp = Math.round(options.borderWidth) % 2 / 2,
       nodeOffset = column.sankeyColumn.offset(node,
         translationFactor),
       fromNodeTop = Math.floor(Highcharts.pick(nodeOffset.absoluteTop, (column.sankeyColumn.top(translationFactor) +
         nodeOffset.relativeTop))) + crisp,
       left = Math.floor(this.colDistance * node.column +
         options.borderWidth / 2) + Highcharts.relativeLength(node.options.offsetHorizontal || 0,
         nodeWidth) +
       crisp,
       nodeLeft = chart.inverted ?
       chart.plotSizeX - left :
       left;
     node.sum = sum;

     proceed.apply(this, Array.prototype.slice.call(arguments, 1));

     if (1) {
       // Draw the node
       node.shapeType = 'rect';

       node.nodeX = nodeLeft;
       node.nodeY = fromNodeTop;

       let x = nodeLeft,
         y = fromNodeTop,
         width = node.options.width || options.width || nodeWidth,
         height = node.options.height || options.height || nodeHeight;

       if (chart.inverted) {
         x = nodeLeft - nodeWidth;
         y = chart.plotSizeY - fromNodeTop - nodeHeight;
         width = node.options.height...