-
-
Save Buckwich/1664ec288267b16f3b103622544ac7a7 to your computer and use it in GitHub Desktop.
Revisions
-
Buckwich revised this gist
Feb 4, 2023 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,8 +7,8 @@ Changes: - update usage instruction for new Apps Script IDE - does not need document Id (@steren) - supports named sheet (not default, see customization in `code.gs`) - shows total values (default, see customization in `code.gs` to disable) - added some comments in `code.gs` to highlight customization options -
Buckwich revised this gist
Feb 4, 2023 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -21,12 +21,13 @@ Changes: - select which sheet is the base for the sankey diagram - save the project (no need to deploy) - the layout of the table should be as shown in the [Example Spreadsheet](https://docs.google.com/spreadsheets/d/1IUmvhYuuBvfYEu8OfDczmW6LQW-xaeh5c6rklOg3x-o/) - reload the sheet and click "Custom Scripts" -> "SankeyDiagram" (it can take a view seconds to load the new menu and the diagram) - in case of a private sheet you have to authorize the script (probably marked as unsave developer, but it should be your own google account) ## Usage - Open the same document - Click "Custom Scripts" -> "SankeyDiagram" (it can take a view seconds to load the new menu and the diagram) ## Example Spreadsheet only for format reference, does not show diagram https://docs.google.com/spreadsheets/d/1IUmvhYuuBvfYEu8OfDczmW6LQW-xaeh5c6rklOg3x-o/ -
Buckwich revised this gist
Feb 4, 2023 . 2 changed files with 53 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,15 @@ > This Gist is there to help you creating a Sankey Diagram from your Google Spreadsheets. ## Fork of @njoerd114 Changes: - update usage instruction for new Apps Script IDE - does not need document Id (@steren) - supports named sheet (not default, see cusomization in `code.gs`) - shows total values (default, see cusomization in `code.gs` to disable) - added some comments in `code.gs` to highlight customization options ## Installation This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,23 +1,51 @@ function onOpen() { SpreadsheetApp.getUi() // Or DocumentApp or FormApp. .createMenu("Custom Scripts") // Customization: Menu Name .addItem("SankeyDiagram", "openDialog") // Customization: Item Name .addToUi(); } function getSpreadsheetData() { sheet = SpreadsheetApp.getActive().getSheets()[0]; // Customization: Select Sheet (0 is first sheet) // Alternatively use a named sheet // sheet = SpreadsheetApp.getActive().getSheetByName("Sankey") // Customization: Sheet Name data = sheet.getDataRange().getValues(); // Customization: Choose between with/without values // return data; // uncomment this line if you *do not* want to see the values directly return addTotalLabels(data); // uncomment this line if you want to see the values directly } function openDialog() { let html = HtmlService.createHtmlOutputFromFile("index") .setHeight(300) .setWidth(1000); SpreadsheetApp.getUi() // Or DocumentApp or FormApp. .showModalDialog(html, "Sankey Diagram"); // Customization: Diagram Title } function addTotalLabels(rows) { let srcTotals = sumValuesByKey(rows, 0, 2); let dstTotals = sumValuesByKey(rows, 1, 2); rows.forEach((row) => { row[0] = `${row[0]} (${srcTotals[row[0]]})`; row[1] = `${row[1]} (${dstTotals[row[1]]})`; }); return rows; } function sumValuesByKey(array, keyIndex, valueIndex) { let result = {}; for (let i = 0; i < array.length; i++) { let key = array[i][keyIndex]; let value = array[i][valueIndex]; if (result[key]) { result[key] += value; } else { result[key] = value; } } return result; } -
Buckwich revised this gist
Feb 4, 2023 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,8 @@ # Sankey Diagrams within Google Spreadsheets > This Gist is there to help you creating a Sankey Diagram from your Google Spreadsheets. > Fork of @njoerd114 to update instructions ## Installation -
Buckwich revised this gist
Feb 4, 2023 . 1 changed file with 9 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,18 +4,23 @@ > This Gist is there to help you creating a Sankey Diagram from your Google Spreadsheets. > Fork of [](http://niklasbeinghaus.com) to update instructions ## Installation - Open a spreadsheet - Click "Extensions" -> "App Script" - create the two files `code.gs` and `index.html` and paste to code of this gist - insert the document ID from the URL on line 10, `code.gs` - select which sheet is the base for the sankey diagram - save the project (no need to deploy) - the layout of the table should be as shown in the [Example Spreadsheet](https://docs.google.com/spreadsheets/d/1IUmvhYuuBvfYEu8OfDczmW6LQW-xaeh5c6rklOg3x-o/) - reload the sheet and click "Zusatzfunktionen" -> "SankeyDiagram" - in case of a private sheet you have to authorize the script (probably marked as unsave developer, but it should be your own google account) ## Usage - Open the same document - Click "Zusatzfunktionen" -> "SankeyDiagram" (it caan take a view seconds to load the new menu and the diagram) ## Example Spreadsheet https://docs.google.com/spreadsheets/d/1IUmvhYuuBvfYEu8OfDczmW6LQW-xaeh5c6rklOg3x-o/ -
njoerd114 revised this gist
Jun 9, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ - create the two files `code.gs` and `index.html` - insert the document ID from the URL on line 10, `code.gs` - select which sheet is the base for the sankey diagram - the layout of the table should be as shown in the [Example Spreadsheet](https://docs.google.com/spreadsheets/d/1IUmvhYuuBvfYEu8OfDczmW6LQW-xaeh5c6rklOg3x-o/) ## Usage - Open the same document -
njoerd114 revised this gist
Jun 9, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -18,4 +18,4 @@ - Click "Zusatzfunktionen" -> "SankeyDiagram" ## Example Spreadsheet https://docs.google.com/spreadsheets/d/1IUmvhYuuBvfYEu8OfDczmW6LQW-xaeh5c6rklOg3x-o/ -
njoerd114 revised this gist
Jun 9, 2020 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,4 +17,5 @@ - Open the same document - Click "Zusatzfunktionen" -> "SankeyDiagram" ## Example Spreadsheet https://docs.google.com/spreadsheets/d/1IUmvhYuuBvfYEu8OfDczmW6LQW-xaeh5c6rklOg3x-o/edit?usp=sharing -
njoerd114 revised this gist
Jun 9, 2020 . No changes.There are no files selected for viewing
-
njoerd114 revised this gist
Jun 9, 2020 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,4 +12,9 @@ - insert the document ID from the URL on line 10, `code.gs` - select which sheet is the base for the sankey diagram - the layout of the table should be ## Usage - Open the same document - Click "Zusatzfunktionen" -> "SankeyDiagram" source | destination | value -
njoerd114 created this gist
Jun 9, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ <!-- [](http://niklasbeinghaus.com) --> # Sankey Diagrams within Google Spreadsheets > This Gist is there to help you creating a Sankey Diagram from your Google Spreadsheets. ## Installation - Open a spreadsheet - Click "Tools" -> "Scripts" - create the two files `code.gs` and `index.html` - insert the document ID from the URL on line 10, `code.gs` - select which sheet is the base for the sankey diagram - the layout of the table should be source | destination | value This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ function onOpen() { SpreadsheetApp.getUi() // Or DocumentApp or FormApp. .createMenu('Zusatzfunktionen') .addItem('SankeyDiagram', 'openDialog') .addToUi(); } function getSpreadsheetData() { // ID of your Document, take from URL var ssID = "", // which Sheet? [0] is the first and so on... sheet = SpreadsheetApp.openById(ssID).getSheets()[0], data = sheet.getDataRange().getValues(); return data; } function openDialog() { var html = HtmlService.createHtmlOutputFromFile('index') .setHeight(300) .setWidth(1000); SpreadsheetApp.getUi() // Or DocumentApp or FormApp. .showModalDialog(html, 'Sankey Diagram'); } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ <!DOCTYPE html> <html> <head> <base target="_top"> <script src="https://www.google.com/jsapi"></script> </head> <body> <div id="main"></div> <script type="text/javascript"> google.load('visualization', '1', { packages: ['corechart', 'sankey'] }); google.setOnLoadCallback(initialize); function initialize() { google.script.run.withSuccessHandler(drawChart).getSpreadsheetData(); } function drawChart(rows) { console.log(rows); var data = google.visualization.arrayToDataTable(rows); var chart = new google.visualization.Sankey(document.getElementById('main')); chart.draw(data, {width: 900, sankey: {iterations: 64}}); } </script> </body> </html>