Sankey Diagram highchart Issue

问题描述 投票:0回答:1

enter image description here

嗨,

我想生成如下所示的Sankey图,截至目前,我正在使用像这样的序列数据:

 keys: ['from', 'to' ,'weight'],
        data: [
        ['Entrance  A', 'Platform 1' , 10 ],
        ['Entrance  A', 'Platform 2' , 2 ],
        ['Entrance B', 'Platform 2' , 3 ],
        ['Entrance C', 'Platform 3' , 5 ],
        ['Entrance D', 'Platform 4' , 7 ],
        ['Entrance E', 'Platform 1' , 6 ],
        ['Entrance F', 'Platform 2' , 10 ],
        ['Entrance F', 'Platform 4' , 4 ],
        ['Entrance G', 'Platform 1' , 13 ],
        ['Platform 1', 'Exit F' , 9 ],
        ['Platform 2', 'Exit D' , 10 ],
        ['Platform 2', 'Exit F' , 4 ],
        ['Platform 3', 'Exit G' , 5 ],
        ['Platform 3', 'Exit B' , 11 ],
        ['Platform 4', 'Exit C' , 5 ],
        ['Platform 4', 'Exit E' , 6]
        ]

但是这会生成三个节点图enter image description here

我应该使用哪种数据来获得与图像1中给出的图形类似的图形

highcharts angular6
1个回答
0
投票

对于平台,您可以创建两种类型的节点:“ X平台从”和“ X平台到”。然后,您可以使用nodes部分重新定义它们,以便它们具有相同的名称和相同的颜色:

series: [{
    type: 'sankey',
    keys: ['from', 'to' ,'weight'],
    data: [
        ['Entrance A', 'Platform 1 to' , 10 ],
        ['Entrance A', 'Platform 2 to' , 2 ],
        ['Entrance B', 'Platform 2 to' , 3 ],
        ['Entrance C', 'Platform 3 to' , 5 ],
        ['Entrance D', 'Platform 4 to' , 7 ],
        ['Entrance E', 'Platform 1 to' , 6 ],
        ['Entrance F', 'Platform 2 to' , 10 ],
        ['Entrance F', 'Platform 4 to' , 4 ],
        ['Entrance G', 'Platform 1 to' , 13 ],
        ['Platform 1 from', 'Exit F' , 9 ],
        ['Platform 2 from', 'Exit D' , 10 ],
        ['Platform 2 from', 'Exit F' , 4 ],
        ['Platform 3 from', 'Exit G' , 5 ],
        ['Platform 3 from', 'Exit B' , 11 ],
        ['Platform 4 from', 'Exit C' , 5 ],
        ['Platform 4 from', 'Exit E' , 6]
    ],
    nodes: [
        {id: 'Platform 1 from', 'name': 'Platform 1', colorIndex: 0},
        {id: 'Platform 1 to',   'name': 'Platform 1', colorIndex: 0},

        {id: 'Platform 2 from', 'name': 'Platform 2', colorIndex: 1},
        {id: 'Platform 2 to',   'name': 'Platform 2', colorIndex: 1},

        {id: 'Platform 3 from', 'name': 'Platform 3', colorIndex: 2},
        {id: 'Platform 3 to',   'name': 'Platform 3', colorIndex: 2},

        {id: 'Platform 4 from', 'name': 'Platform 4', colorIndex: 3},
        {id: 'Platform 4 to',   'name': 'Platform 4', colorIndex: 3},
    ]
}]
© www.soinside.com 2019 - 2024. All rights reserved.