Skip to content

Instantly share code, notes, and snippets.

@gabiborges1
Last active April 19, 2021 20:42
Show Gist options
  • Save gabiborges1/89d1a68d2f19c614580d3e4d968d588f to your computer and use it in GitHub Desktop.
Save gabiborges1/89d1a68d2f19c614580d3e4d968d588f to your computer and use it in GitHub Desktop.
LearnIT sankey
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<!-- Load the sankey.js function -->
<script src="https://cdn.jsdelivr.net/gh/holtzy/D3-graph-gallery@master/LIB/sankey.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<div id="my_dataviz"></div>
<script>
var formatNumber = d3.format(",.0f");
// set the dimensions and margins of the graph
var margin = {top: 10, right: 10, bottom: 10, left: 10},
width = 450 - margin.left - margin.right,
height = 480 - margin.top - margin.bottom;
// append the svg object to the body of the page
var svg = d3.select("#my_dataviz").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform",
"translate(" + margin.left + "," + margin.top + ")");
// Color scale used
var color = d3.scaleOrdinal(d3.schemeCategory20);
// Set the sankey diagram properties
var sankey = d3.sankey()
.nodeWidth(36)
.nodePadding(40)
.size([width, height]);
</script>
</body>
{"nodes": [{"node": 0, "name": "Publicacao Edital", "height": 0.7868410927279723}, {"node": 1, "name": "Abertura Licitacao", "height": 1.0}, {"node": 2, "name": "Homologacao de Licitacoes", "height": 0.632935744517122}, {"node": 3, "name": "Encerramento Licitacao", "height": 0.8460946517891497}], "links": [{"source": 4, "target": 1, "value": 0.6991478756019989, "pad": 19.46153846153846}, {"source": 1, "target": 3, "value": 0.6294728741823779, "pad": 53.68092909535452}, {"source": 3, "target": 2, "value": 0.6321662177760677, "pad": 54.44917833231893}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment