Created
April 15, 2020 23:29
-
-
Save franklinbaldo/c25d7b12c60db3cbdebab87a206c6a94 to your computer and use it in GitHub Desktop.
google charts sankey
This file contains 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
<html> | |
<head> | |
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | |
<script type="text/javascript"> | |
google.charts.load('current', {'packages':['sankey']}); | |
google.charts.setOnLoadCallback(drawChart); | |
function drawChart() { | |
var data = new google.visualization.DataTable(); | |
data.addColumn('string', 'From'); | |
data.addColumn('string', 'To'); | |
data.addColumn('number', 'Weight'); | |
data.addRows([ | |
[ 'A', 'X', 5 ], | |
[ 'A', 'Y', 7 ], | |
[ 'A', 'Z', 6 ], | |
[ 'B', 'X', 2 ], | |
[ 'B', 'Y', 9 ], | |
[ 'B', 'Z', 4 ] | |
]); | |
// Sets chart options. | |
var options = { | |
width: 600, | |
}; | |
// Instantiates and draws our chart, passing in some options. | |
var chart = new google.visualization.Sankey(document.getElementById('sankey_basic')); | |
chart.draw(data, options); | |
} | |
</script> | |
</head> | |
<body> | |
<div id="sankey_basic" style="width: 900px; height: 300px;"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment