上一篇: 仪表盘图 https://blog.csdn.net/zjw_python/article/details/98596174
下一篇: 旭日图 https://blog.csdn.net/zjw_python/article/details/98613674
代码结构和初始化画布的Chart对象介绍,请先看 https://blog.csdn.net/zjw_python/article/details/98182540
本图完整的源码地址: https://github.com/zjw666/D3_demo/tree/master/src/sanKeyChart/basicSanKey
1 图表效果
2 数据
桑基图的数据需要符合一定的规则,即包含nodes和links两个部分
{
"nodes": [
{
"id": "a"},
{
"id": "b"},
{
"id": "c"},
{
"id": "d"},
{
"id": "e"},
{
"id": "f"},
{
"id": "g"},
{
"id": "h"},
{
"id": "i"}
],
"links": [
{
"source": "a", "target": "d", "value": 10},
{
"source": "a", "target": "i", "value": 2},
{
"source": "b", "target": "d", "value": 8},
{
"source": "b", "target": "e", "value": 6},
{
"source": "c", "target": "e", "value": 5},
{
"source": "b", "target": "e", "value": 2},
{
"source": "b", "target": "i", "value": 4},
{
"source": "d", "target": "f", "value": 3},
{
"source": "d", "target": "g", "value": 4},
{
"source": "d", "target": "h",