简单的sankey图组件

sankeySimple是一个基于d3库的简单Sankey图表组件,仅包含两个维度。它提供了节点大小、颜色、维度标题和CSS样式的自定义功能。组件可在github上找到,链接为https://github.com/jdk137/sankeySimple。使用该组件需要d3.js和sankey.js作为依赖,并遵循特定的数据格式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

sankeySimple

A simple sankey data visualization base on d3’s sankey.js. Two dimensions only.

github地址:
https://github.com/jdk137/sankeySimple

在这里插入图片描述

Requirements:

d3.js
sankey.js

Features:

  1. Two dimension split.

  2. self defined node size, node color, dimension title and css style.

Usage:

        var sankeySimple = new SankeySimple(document.getElementById('chart'), {
          data: data,
          // width: 700,
          // height: 800,
          // nodeWidth: 36,
          // nodePadding: 12,
          // margin: { top: 50, right: 50, bottom: 50, left: 50 },
          // leftTitle: 'Delegations',
          // rightTitle: 'Parties',
          // color: d3.scaleOrdinal(d3.schemeCategory20),
        });

Data format:

  {
    "nodes": [
      { "node": 0, "name": "Anhui", "color": "#9E0142"}, // color is optional
      { "node": 1, "name": "CPC (Communist Party of China)", "color": "#D53E4F"},
      { "node": 2, "name": "Hunan", "color": "#F46D43" },
      { "node": 3, "name": "No party affiliation", "color": "#FDAE61"}
    ],
    "links": [
      { "source": 0, "target": 1, "value": 1 },
      { "source": 0, "target": 3, "value": 2 },
      { "source": 2, "target": 1, "value": 2 },
      { "source": 2, "target": 3, "value": 1 }
    ]
  }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值