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([ [ 'Vegetables 70.2%','', 1], [ 'Fruits 29.8%', 'Orange 9%', 9 ], [ 'Fruits 29.8%', 'Apple 8.6%', 8.6 ], [ 'Fruits 29.8%', 'Banan 7.9%', 7.9 ], [ 'Fruits 29.8%', 'Grapes 4.3%', 4.3 ], [ 'Orange 9%', 'Apple 4.0%', 4.0 ], [ 'Orange 9%', 'Banana 3.2%', 3.2 ], [ 'Orange 9%', 'Grapes 1.7%', 1.7 ], [ 'Apple 8.6%', 'Orange 4.8%', 4.8 ], [ 'Apple 8.6%', 'Banana 2.0%', 2.0 ], [ 'Apple 8.6%', 'Grapes 1.8%', 1.8 ], [ 'Banana 7.9%', 'Orange 3.4%', 3.4 ], [ 'Banana 7.9%', 'Apple 2.9%', 2.9 ], [ 'Banana 7.9%', 'Grapes 2.4%', 1.7 ], [ 'Grapes 4.3%', 'Orange 1.6%', 1.6 ], [ 'Grapes 4.3%', 'Banana 1.4%', 1.4 ], [ 'Grapes 4.3%', 'Apple 1.3%', 1.3 ], ]); var options = { width: 1000, height:600, sankey: { node: { label: { fontName: 'sans-serif', fontSize: 17, color: '#000', bold: true, italic: false }, interactivity: true, labelPadding: 10, nodePadding: 10, } } }; var container = document.getElementById('sankey_basic'); var chart = new google.visualization.Sankey(container);
<script src="https://www.gstatic.com/charts/loader.js"></script> <div id="sankey_basic"></div>