首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sankey Diagram高度表问题

Sankey Diagram高度表问题
EN

Stack Overflow用户
提问于 2020-03-29 02:14:23
回答 1查看 113关注 0票数 0

我想生成一个像下面这样的Sankey Diagram,到目前为止,我使用的数据是这样的系列:

代码语言:javascript
复制
 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]
        ]

但这会生成三个节点图

我应该使用什么类型的数据来获得与图1中给出的类似类型的图形

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-29 21:06:19

对于平台,您可以创建两种类型的节点:'Platform X from‘和'Platform X to’。然后,可以使用nodes部分重新定义它们,使它们具有相同的名称和相同的颜色:

代码语言:javascript
复制
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},
    ]
}]
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60904956

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档