This Gist is there to help you creating a Sankey Diagram from your Google Spreadsheets.
Go to my template Spreadsheet, go to File -> Create a copy.
This will copy the AppScript in a new project that you can start modifying.
If you already have the "Extensions" menu in the top toolbar, proceed to the next section.
Otherwise, it looks like Google Spreadsheets "Extensions" menu is not enabled by default. You might have to go to https://script.google.com/home and create a new project from there to make this menu appear.
- Open a Spreadsheet
- Click "Extensions" -> "Apps Scripts"
- You should have a
Code.gs
file open, paste the corresponding code - Click on the
+
button on the left side to create a new file, chooseHTML
; name itìndex
(extension is added automatically - Paste the
index.html
code from below in there - Switch back to the Spreadsheet, reload the page to load the script
You should now have a "Diagrams" menu in the top toolbar.
- Open a document for which you installed the script
- Click "Diagrams" -> "Sankey"
This can take a few seconds, then you will see the diagram in a dialog window.
You can click on "Copy image" to get a PNG version of the diagram that you can paste directly in your spreadsheet.
https://docs.google.com/spreadsheets/d/1Qn5JXeWBFCneHvwyJjfHhZ0TB-ee1Lm9xpJ_9gAsDbY/edit?usp=sharing
I changed your code too much while figuring out this problem so this is the easiest way.
Here's a function you need to add:
Then where the serializer is called, change the parameter to call
cloneSVG()
like belowTo add gradients, add the following just before the call to
chart.draw(data, options);