Skip to content

Instantly share code, notes, and snippets.

@DerekCaelin
Last active May 18, 2017 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DerekCaelin/e02a8857b93378224ec673acf2f82910 to your computer and use it in GitHub Desktop.
Save DerekCaelin/e02a8857b93378224ec673acf2f82910 to your computer and use it in GitHub Desktop.
fresh block
license: mit
<!DOCTYPE html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="sankey_basic" style="width: 100%; height: 400px;"></div>
</head>
<body>
<script>
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([
['Conflicts between Boko Haram and the government', 'Local Government Officials', 44],
['Conflicts between Boko Haram and the government', 'National Government Officials', 27],
['Conflicts between Boko Haram and the government', 'Police', 74],
['Conflicts between Boko Haram and the government', 'Religious Leaders', 61],
['Conflicts between Boko Haram and the government', 'State Government Officials', 33],
['Conflicts between Boko Haram and the government', 'Traditional or Community Leaders', 133],
['Conflicts between farmers and herders or other rural banditry', 'Local Government Officials', 15],
['Conflicts between farmers and herders or other rural banditry', 'National Government Officials', 5],
['Conflicts between farmers and herders or other rural banditry', 'Police', 43],
['Conflicts between farmers and herders or other rural banditry', 'Religious Leaders', 50],
['Conflicts between farmers and herders or other rural banditry', 'State Government Officials', 17],
['Conflicts between farmers and herders or other rural banditry', 'Traditional or Community Leaders', 124],
['Ethnic and Religious Tensions', 'Local Government Officials', 11],
['Ethnic and Religious Tensions', 'National Government Officials', 9],
['Ethnic and Religious Tensions', 'Police', 57],
['Ethnic and Religious Tensions', 'Religious Leaders', 48],
['Ethnic and Religious Tensions', 'State Government Officials', 18],
['Ethnic and Religious Tensions', 'Traditional or Community Leaders', 77],
['Political grievances and economic instability', 'Local Government Officials', 12],
['Political grievances and economic instability', 'National Government Officials', 9],
['Political grievances and economic instability', 'Police', 28],
['Political grievances and economic instability', 'Religious Leaders', 15],
['Political grievances and economic instability', 'State Government Officials', 9],
['Political grievances and economic instability', 'Traditional or Community Leaders', 38]
]);
var colors = ['#00cc00', '#0000ff', '#ff6600', '#669999',
'#ff33cc', '#ff9933', '#1f78b4', '#ffff00'
];
// Sets chart options.
var options = {
sankey: {
node: {
colors: colors,
label: {
fontSize: 14,
color: '#871b47',
// bold: true,
}
},
link: {
colorMode: 'gradient',
colors: colors
}
}
};
// Instantiates and draws our chart, passing in some options.
var chart = new google.visualization.Sankey(document.getElementById('sankey_basic'));
chart.draw(data, options);
}
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment