sathishkumar
sathishkumar

Reputation: 1816

Highchart Sankey is not working with same from value as to value settings

My JSfiddle: https://jsfiddle.net/sathishkumar_v/sw0fa4m8/2/.

Highcharts.chart('container', {
  title: {
    text: 'Highcharts Sankey Diagram'
  },
  series: [{
    keys: ['from', 'to', 'weight'],
    data: [
        ['Brazil', 'Portugal', 5 ],
        ['Brazil', 'France', 1 ],
        ['Brazil', 'Spain', 1 ],
        ['Brazil', 'England', 1 ],
        ['Canada', 'Portugal', 1 ],
        ['Canada', 'France', 5 ],
        ['Canada', 'England', 1 ],
        ['Canada', 'Brazil', 4 ],
    ],
    type: 'sankey',
    name: 'Sankey demo series'
  }]
});

We have two from side labels: Brazil, and Canada. The to side has the labels: Portugal, France, Spain, England, and Brazil.

The plotted graph is failing to display the Brazil label at right side as expected. Instead, it is showing the Brazil label in the bottom left corner.

Upvotes: 0

Views: 458

Answers (1)

Core972
Core972

Reputation: 4114

I think you will need to change the data order like that :

    data: [
        ['Canada', 'Brazil', 4 ], // In first position
        ['Brazil', 'Portugal', 5 ],
        ['Brazil', 'France', 1 ],
        ['Brazil', 'Spain', 1 ],
        ['Brazil', 'England', 1 ],
        ['Canada', 'Portugal', 1 ],
        ['Canada', 'France', 5 ],
        ['Canada', 'England', 1 ],
    ],

Fiddle

Edit 2nd solution

Use nodes Api Doc

    data: [
        ['Brazil', 'Portugal', 5 ],
        ['Brazil', 'France', 1 ],
        ['Brazil', 'Spain', 1 ],
        ['Brazil', 'England', 1 ],
        ['Canada', 'Portugal', 1 ],
        ['Canada', 'France', 5 ],
        ['Canada', 'England', 1 ],
        ['Canada', 'Brazil-end', 4 ],
    ],
    nodes: [{
        id: 'Brazil-end',
        name: 'Brazil'
      }
    ],

Fiddle

Upvotes: 3

Related Questions