Skip to main content
100%

SANKEY Experiment

✓ Published0🌍 Public
EEE2dev
Last edited Sep 17, 2017
Created on Aug 10, 2017

This example shows a Sankey diagram with a custom modification to the link-drawing function in d3 v4. When two connected nodes share the same x position, their links curve in an S-shape instead of the standard arc. The layout is computed with d3.sankey(), using SVG rendering and drag-and-drop interactivity. Data comes from a JSON file, and the visualization colors nodes and weights links by flow value, with hover tooltips. The key code change is a single line in sankey.js’s link function: it checks whether the absolute difference between source and target x positions is less than the source node’s width, and if so, sets the curvature to -2 to create the S-curve; otherwise, it keeps the default curvature of 0.5. This fork builds on d3noob’s block for D3 v4.

AI-generated description

This is a test for adjusting the link function in sankey.js to account for the following case: If two connected nodes are at the same x position, their link should be an S-like curve.

It just takes to add one additional line in the link function of sankey.js.

This is based on one of the code samples for the update to the book D3 Tips and Tricks to version 4 of d3.js.

forked from <a href='http://bl.ocks.org/d3noob/'>d3noob</a>'s block: <a href='http://bl.ocks.org/d3noob/013054e8d7807dff76247b81b0e29030'>Sankey Diagram with curved vertical links</a>

mit Licensed

Similar vizzes