Aniket Tiwari
Aniket Tiwari

Reputation: 3998

Draw sankey when multiple entries have the same name

While forming a new node from the child node with the same name I am unable to form a new node out of it. Instead of forming a node from the child node, it is creating a new node from start I read a few articles regarding name clashes but still I unable to figure out the solution

In my case, I have two nodes cricket and sports with the same child node others. So, it should treat multiple entries having the same name independently

Highcharts.chart('container', {

    title: {
        text: ''
    },
    xAxis: {
        type: 'pre-instituion, and trail phase'
    },

    series: [{
        keys: ['from', 'to', 'weight', 'tooltip'],
        data:  [
                ['Apple', 'sports', 34],
                ['sports', 'cricket', 15],
                ['sports', 'footbal', 10],
                ['sports', 'basketball', 1],
                ['sports', 'Others', 1],
                ['cricket', 'sachin', 15],
                ['cricket', 'Others', 15],

                ['Google', 'sports', 24],
                ['sports', 'cricket', 15],
                ['sports', 'footbal', 20],
                ['sports', 'basketball', 1],
                ['sports', 'Others', 1],
                ['Alphabet', 'sports', 24],
                ['sports', 'cricket', 15],
                ['sports', 'footbal', 20],
                ['sports', 'basketball', 1],
                ['sports', 'Others', 1]
              ],
        type: 'sankey'


    }]

});

Here is the sankey link

Upvotes: 0

Views: 916

Answers (1)

ppotaczek
ppotaczek

Reputation: 39099

You need to use distinct values in the data and use nodes to format names in any way:

series: [{
    nodes: [{
        id: 'Others-l3',
        name: 'Others'
    }],
    ...
}]

Live demo: https://jsfiddle.net/BlackLabel/oqbtg94k/

API Reference: https://api.highcharts.com/highcharts/series.sankey.nodes

Upvotes: 1

Related Questions