Created
September 5, 2019 23:46
-
-
Save adept/59f3be91b95c98d1963b5161d0c9c3d8 to your computer and use it in GitHub Desktop.
Highcharts Sankey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<html> | |
<body> | |
<!-- Styles --> | |
<style> | |
#container { | |
min-width: 300px; | |
max-width: 1600px; | |
height: 1000px; | |
margin: 1em auto; | |
border: 1px solid silver; | |
} | |
#csv { | |
display: none; | |
} | |
</style> | |
<script src="https://code.highcharts.com/highcharts.js"></script> | |
<script src="https://code.highcharts.com/modules/sankey.js"></script> | |
<script src="https://code.highcharts.com/modules/exporting.js"></script> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<div id="container"></div> | |
<!-- Chart code --> | |
<script> | |
var raw_data = []; | |
d3.csv("sankey.csv", function(error, data) { | |
console.log(error); | |
data.forEach(function (d) { | |
console.log(d); | |
raw_data.push([d.source, d.target, +d.value]); | |
}); | |
Highcharts.chart('container', { | |
title: { | |
text: 'Highcharts Sankey Diagram' | |
}, | |
series: [{ | |
keys: ['from', 'to', 'weight'], | |
data: raw_data, | |
type: 'sankey', | |
name: 'Sankey demo series' | |
}] | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment