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([ ['Kristen Lavransdatter', 'Fiction', 1], ['Kristen Lavransdatter', 'Historical Fiction', 4], ['Kristen Lavransdatter', 'Europe', 5], ['Brooklyn', 'Fiction', 1], ['Brooklyn', 'Historical Fiction', 1], ['Brooklyn', 'Europe', 1], ['Brooklyn', 'US', 1], ['Insanely Simple', 'NonFiction', 1], ['Insanely Simple', 'Business', 1], ['Insanely Simple', 'Meh', 5], ['The Circle', 'Fiction', 1], ['The Circle', 'US', 1], ['The Circle', 'Meh', 3], ['The Monuments Men', 'NonFiction', 1], ['The Monuments Men', 'History', 5], ['The Monuments Men', 'Europe', 3], ['The Secret Garden', 'Fiction', 1], ['The Secret Garden', 'Classics', 5], ['The Secret Garden', 'Europe', 3], ['My Brilliant Friend', 'Fiction', 1], ['My Brilliant Friend', 'Historical Fiction', 2], ['My Brilliant Friend', 'Europe', 5], ['The Story of a New Name', 'Fiction', 1], ['The Story of a New Name', 'Historical Fiction', 2], ['The Story of a New Name', 'Europe', 5], ['Those Who Leave and Those Who Stay', 'Fiction', 1], ['Those Who Leave and Those Who Stay', 'Historical Fiction', 2], ['Those Who Leave and Those Who Stay', 'Europe', 5], ['The Story of a Lost Child', 'Fiction', 1], ['The Story of a Lost Child', 'Historical Fiction', 2], ['The Story of a Lost Child', 'Europe', 5], ['Up From Slavery', 'NonFiction', 1], ['Up From Slavery', 'History', 3], ['Up From Slavery', 'Auto/Biography', 5], ['Up From Slavery', 'Race', 5], ['Up From Slavery', 'US', 5], ['Elon Musk', 'NonFiction', 1], ['Elon Musk', 'Auto/Biography', 5], ['Elon Musk', 'Business', 3], ['Between the World and Me', 'NonFiction', 1], ['Between the World and Me', 'Auto/Biography', 3], ['Between the World and Me', 'Race', 5], ['Between the World and Me', 'US', 5], ['Just Mercy', 'NonFiction', 1], ['Just Mercy', 'Race', 5], ['Just Mercy', 'US', 5], ['Seeing and Savoring Jesus Christ', 'NonFiction', 1], ['Seeing and Savoring Jesus Christ', 'Religion', 5], ['The Clasp', 'Fiction', 1], ['The Clasp', 'Meh', 4], ['The Snowball', 'NonFiction', 1], ['The Snowball', 'Auto/Biography', 5], ['The Snowball', 'US', 1], ['The Snowball', 'Business', 4], ['Career of Evil', 'Fiction', 1], ['Career of Evil', 'Thriller', 5], ['Career of Evil', 'Europe', 1], ['When Breath Becomes Air', 'NonFiction', 1], ['When Breath Becomes Air', 'Auto/Biography', 5], ['The Worst Hard Time', 'NonFiction', 1], ['The Worst Hard Time', 'History', 5], ['The Worst Hard Time', 'US', 5], ['Essentialism', 'NonFiction', 1], ['Essentialism', 'Self-Improvement', 5], ['Why Nations Fail', 'NonFiction', 1], ['Why Nations Fail', 'History', 3], ['Undaunted Courage', 'NonFiction', 1], ['Undaunted Courage', 'History', 5], ['Undaunted Courage', 'US', 5], ['Crossing to Safety', 'Fiction', 1], ['Crossing to Safety', 'Meh', 5], ['Smarter Better Faster', 'NonFiction', 1], ['Smarter Better Faster', 'Self-Improvement', 4], ['I Am Pilgrim', 'Fiction', 1], ['I Am Pilgrim', 'Thriller', 5], ['Confessions of an Economic Hitman', 'NonFiction', 1], ['Confessions of an Economic Hitman', 'Auto/Biography', 3], ['Confessions of an Economic Hitman', 'US', 1], ['Confessions of an Economic Hitman', 'Meh', 4], ['Being Mortal', 'US', 3], ['Being Mortal', 'NonFiction', 1], ['Being Mortal', 'Auto/Biography', 3], ['Better Than Before', 'NonFiction', 1], ['Better Than Before', 'Self-Improvement', 5], ['Stoner', 'Fiction', 1], ['Stoner', 'Classics', 3], ['Open', 'NonFiction', 1], ['Open', 'Auto/Biography', 5], ['Mr. Penumbras 24 Hour Book Store', 'Fiction', 1], ['Mr. Penumbras 24 Hour Book Store', 'Meh', 4], ['Inferno: The World at War', 'US', 2], ['Inferno: The World at War', 'Russia', 4], ['Inferno: The World at War', 'Europe', 4], ['Inferno: The World at War', 'NonFiction', 1], ['Inferno: The World at War', 'History', 5], ['The Tiger: a True Story of Vengeance and Survival ', 'Russia', 5], ['The Tiger: a True Story of Vengeance and Survival ', 'History', 3], ['The Tiger: a True Story of Vengeance and Survival ', 'NonFiction', 1], ['Things Ive Been Silent About', 'NonFiction', 1], ['Things Ive Been Silent About', 'Auto/Biography', 5], ]); // Sets chart options. var options = { width: 600, sankey: { link: { color: { fill:'#5f5f5f'} }, node: { colors: [ '#0a4e48','#107b72', '#16a89c','#1cd5c6','#3ee6d8'], label: { color: '#000000', fontsize:14, bold: true} }, } }; // Instantiates and draws our chart, passing in some options. var chart = new google.visualization.Sankey(document.getElementById('sankey_basic')); chart.draw(data, options); }