Search code examples
javascripthighchartsaxis-labelssankey-diagram

Highcharts JS - Sankey Diagram Axis


I am implementing a Sankey Diagram using Highcharts JS and have a problem with specifying the axis. Is it even possible to use xAxis and yAxis on a Sankey diagram?

I tried specifying the axis as following:

 yAxis: {
            title: {
                text: 'Test',
            }
        },
 xAxis: {
            title: {
                text: 'Test'
            }
        },

but with no success. I tried putting the aforementioned code in series, plotOptions.sankey, plotOptions.series and simply when instantiating the chart but with no result.

Looking forward to your help!


Solution

  • Yes. Use chart.showAxes option:

      chart: {
        showAxes: true
      },
    

    Unfortunately in sankey series ticks are not generated for the y axis. It can be done manually like this:

      yAxis: [{
        lineWidth: 1,
        tickPositions: [0, 1, 2, 3]
      }],
    

    Live demo: http://jsfiddle.net/BlackLabel/z5p9gba2/

    API references: