D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
flaneuse
Full window
Github gist
sankey test
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v4.min.js"></script> <script src="sankey.js"></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } </style> </head> <body> <script> // based on Mike Bostock's https://blockbuilder.org/mbostock/ca9a0bb7ba204d12974bca90acc507c0 // hand creating a simple structure for nodes/links var energy = {'nodes': [{'id': 'A', 'value': 10}, {'id': 'B', 'value': 2}, {'id': 'C', 'value': 5}, , {'id': 'D', 'value': 1}], 'links':[{'source': 'A', 'target': 'B', 'value': 3}, {'source': 'B', 'target': 'C', 'value': 6}, {'source': 'B', 'target': 'D', 'value': 8}]}; // set the dimensions and margins of the graph var margin = {top: 10, right: 10, bottom: 10, left: 10}, width = window.innerWidth - margin.left - margin.right, height = window.innerHeight - margin.top - margin.bottom; var svg = d3.select("body") .append('svg') .attr('width', width) .attr('height', height); var sankey = d3.sankey() </script> </body>
https://d3js.org/d3.v4.min.js