All Projects β†’ q-m β†’ D3.chart.sankey

q-m / D3.chart.sankey

Licence: mit
Reusable D3 Sankey diagram using d3.Chart

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to D3.chart.sankey

Rumble Charts
React components for building composable and flexible charts
Stars: ✭ 293 (+184.47%)
Mutual labels:  chart, d3
Billboard.js
πŸ“Š Re-usable, easy interface JavaScript chart library based on D3.js
Stars: ✭ 5,032 (+4785.44%)
Mutual labels:  chart, d3
Britecharts
Client-side reusable Charting Library based on D3.js v5 that allows easy and intuitive use of charts and components that can be composed together creating amazing visualizations.
Stars: ✭ 3,688 (+3480.58%)
Mutual labels:  chart, d3
React Charts
βš›οΈ Simple, immersive & interactive charts for React
Stars: ✭ 1,302 (+1164.08%)
Mutual labels:  chart, d3
D3.js Network Topology
η½‘η»œζ‹“ζ‰‘ε›Ύ
Stars: ✭ 60 (-41.75%)
Mutual labels:  chart, d3
Plottable
πŸ“Š A library of modular chart components built on D3
Stars: ✭ 2,834 (+2651.46%)
Mutual labels:  chart, d3
Vue D3 Network
Vue component to graph networks using d3-force
Stars: ✭ 415 (+302.91%)
Mutual labels:  chart, d3
multi-verse
lit-element components for fast and modular multivariate analysis
Stars: ✭ 34 (-66.99%)
Mutual labels:  d3, chart
D3 Spotmatrix
Open Source Javascript Library to render Spot Matrix Charts using D3.js
Stars: ✭ 12 (-88.35%)
Mutual labels:  chart, d3
D3fc
A collection of components that make it easy to build interactive charts with D3
Stars: ✭ 898 (+771.84%)
Mutual labels:  chart, d3
C3
πŸ“Š A D3-based reusable chart library
Stars: ✭ 9,163 (+8796.12%)
Mutual labels:  chart, d3
Ember C3
πŸ“ˆ Ember addon library for C3, a D3-based reusable chart library.
Stars: ✭ 81 (-21.36%)
Mutual labels:  chart, d3
comparative-layout-explorer
πŸ“Š x πŸ“Š =❓An online gallery to explore the design space of comparative layouts
Stars: ✭ 16 (-84.47%)
Mutual labels:  d3, chart
D3 Funnel
A JavaScript library for rendering funnel charts using the D3.js framework.
Stars: ✭ 283 (+174.76%)
Mutual labels:  chart, d3
jelly-chart
Jelly-Chart is a chart library based on D3v4 and SVG.
Stars: ✭ 34 (-66.99%)
Mutual labels:  d3, chart
Ngx Charts
πŸ“Š Declarative Charting Framework for Angular
Stars: ✭ 4,057 (+3838.83%)
Mutual labels:  chart, d3
a2d3
Flexible and extensible D3 directives for Angular 2
Stars: ✭ 22 (-78.64%)
Mutual labels:  d3, chart
d3-dotmatrix
Open Source Javascript library to render Dot Matrix Charts
Stars: ✭ 14 (-86.41%)
Mutual labels:  d3, chart
React D3 Tree
🌳 React component to create interactive D3 tree graphs
Stars: ✭ 543 (+427.18%)
Mutual labels:  chart, d3
Ac D3
Javascript Library for building Audiovisual Charts in D3
Stars: ✭ 76 (-26.21%)
Mutual labels:  chart, d3

d3.chart.sankey

npm version Dependency Status

Reusable D3 Sankey diagram using d3.Chart.

Demos: energy | product | interactive

Usage

Include d3, sankey and d3.chart before d3.chart.sankey:

<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="https://rawgit.com/newrelic-forks/d3-plugins-sankey/v1.1.0/sankey.js"></script>
<script src="https://rawgit.com/misoproject/d3.chart/master/d3.chart.min.js"></script>
<script src="d3.chart.sankey.min.js"></script>

Then build the chart:

var chart = d3.select("#chart").append("svg").chart("Sankey");
chart.draw({nodes: [/*...*/], links: [/*...*/]});

The chart object supports various ways to customize the diagram:

chart
  .nodeWidth(24)    // width of node
  .nodePadding(8)   // vertical space between nodes
  .iterations(32)   // number of layout iterations
  .spread(false)    // whether to spread nodes vertically after layout
  .name(function(n) { return n.name; })               // node label
  .colorNodes('red')                                  // color for nodes
  .colorNodes(d3.chart.category20c())                 // ... or a color scale
  .colorNodes(function(name, node) { return 'red'; }) // ... or a function
  .colorLinks('yellow')                               // color for labels
  .colorLinks(function(link) { /* ... */ })           // ... or a function
  .alignLabel('start')                                // align node labels: start, end, auto
  .alignLabel((n) => n.x > 100 ? 'end' : 'start');    // ... or a function

The spread option does not exist in D3's Sankey plugin and can make some diagrams clearer. When enabled, nodes are distributed over the full height. This may work best when the number of iterations is set to zero.

The following events are emitted on the chart: node:mouseover, node:mouseout, node:click, node:dblclick, link:mouseover, link:mouseout, link:click, link:dblclick. For example:

chart.on('node:click', function(node) {
  alert('Clicked on ' + node.name);
});

AMD, CommonJS, ...

This chart can also be loaded as a module:

var d3 = require('d3');
var Sankey = require('d3.chart.sankey');

var svg = d3.select('svg');
var chart = new Sankey(svg);

Chart types

There are three chart types: Sankey, Sankey.Selection and Sankey.Path. The last two charts add the notion of a selection, which is set on mouseover when hovering a node or path, or when the selection method is called on the chart (which accepts an array of nodes and links). Sankey.Path expands the selection to connected nodes and links.

When loading as a module, you can also access these charts as properties, so instead of new Sankey(g) you'd use new Sankey.Selection(g);

Special theming

If you add a property to a node object named "id", d3.chart.sankey will add an HTML attribute named "data-node-id" with the value of the "id" property to the node's <g> tag.

This allows CSS and non-D3 JavaScript code to target the node with a selector. For example, in CSS:

[data-node-id="some-id"] rect {
  fill: red;
}

... or in JavaScript...

document.querySelectorAll('[data-node-id="some-id"]');

Building

You'll need Node.js, Grunt and Bower. To fetch required dependencies, run the following commands from the root of this repository:

$ npm install
$ bower install

After this, the project can be built by invoking Grunt from within this repository:

$ grunt

To build the project along with a minified version of the library, run grunt release.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].