Code
Execute
<!DOCTYPE html> <html> <head> <title>Google Charts tutorial Tutorial</title> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.charts.load('current', {packages: ['sankey']}); </script> </head> <body> <div id="container" style="width: 550px; height: 400px; margin: 0 auto"></div> <script language="JavaScript"> function drawChart() { // Define the chart to be drawn. var data = new google.visualization.DataTable(); data.addColumn('string', 'From'); data.addColumn('string', 'To'); data.addColumn('number', 'Weight'); data.addRows([ [ 'Brazil', 'China', 5 ], [ 'Brazil', 'France', 1 ], [ 'Brazil', 'Spain', 2 ], [ 'Brazil', 'japan', 3 ], [ 'Canada', 'China', 4 ], [ 'Canada', 'France', 5 ], [ 'Canada', 'japan', 1 ], [ 'Mexico', 'China', 2 ], [ 'Mexico', 'France', 3 ], [ 'Mexico', 'Spain', 5 ], [ 'Mexico', 'japan', 1 ], [ 'USA', 'China', 2 ], [ 'USA', 'France', 3 ], [ 'USA', 'Spain', 4 ], [ 'USA', 'japan', 5 ] ]); // Set chart options var options = { width: 550, sankey: { node: { colors: [ '#a61d4c' ] }, link: { color: { stroke: 'black', strokeWidth: 1 } }, } }; // Instantiate and draw the chart. var chart = new google.visualization.Sankey(document.getElementById('container')); chart.draw(data, options); } google.charts.setOnLoadCallback(drawChart); </script> </body> </html>
Result