Create a Cash Flow Sankey chart

@rayfes would you be comfortable sharing a screenshot?


here’s a screenshot where I set the size to 2000 which means I have to scroll. It would be nice to be able to generate an image file of this chart or have the ability to zoom in and out directly

@rayfes thanks! Which size are you changing and can you share a screenshot without that change?

I’ll look into providing a download link.

There is a download link the latest version.
Regarding size, I expect the google visualization library to work with the provided size within reason. The default I am specifying is around 640 x 640 in code.gs. It seems to work fine for my data without any scrolling. I have also tested with very small sizes - it breaks around 300px. It sounds like for others it is breaking at the default size. If you are comfortable providing data to reproduce, you can turn on debug data dump in sankey.gs line 52. Change from
var dumpData = false;
to
var dumpData = true;

And then run the sankey generation from an empty sheet. This will dump the aggregate transaction amounts being used to generate the chart in that empty sheet. You can obfuscate the categories if you want and share the data with me. That’ll allow me to reproduce what you are seeing and hopefully, fix it.

Super happy with the latest changes you made @purujit.saha !

Sizing looks good and I really like the download link. The test labels all work except for this one that is doubled up on the income side:

image

Any suggestions on what in the data is causing that? I think I’m going to go back and add account and transaction IDs for the last year’s transactions. I assume the transaction IDs need to be unique.

Let me know if there’s a place I can contribute financially for this.

@rayfes you made my day, haha :smile: - no need for financial contribution. Just star the github repo if you haven’t already.
This chart logic does not use the Transaction ID column - just the Account ID. But other tools might. And, yes, it should be unique for each transaction.

Regarding the doubled up label, it is not a data issue. Google charts library automatically lays out the nodes in the chart and sometimes messes up. 2 things you can play around with to see if that fixes it. Find the section in sankey_chart_ui.html that has

                sankey: {
                    iterations: 32,
                    node: {
                        interactivity: true,
                    }
                }

Try different values of iteration from 0 to 100 - this determines how long the library spends trying to find the optimal layout. Sometimes lower is better. 0 means no iterations at all and the order of the input is preserved.

Another one is the nodePadding property. You can try increasing or decreasing it and see if that helps.

                sankey: {
                    iterations: 32,
                    node: {
                        interactivity: true,
                        nodePadding: 10,     // Vertical distance between nodes.
                    }
                }

If you have other cool enhancements for Tiller in mind, please share. It is fun whipping up small apps script tools.

I played around with those and was able to generate a nice sankey chart. I’m all set now and your github repo has been starred :slightly_smiling_face:

I’ve been designing computer chips for 30 years but anything beyond basic procedural programming is beyond me so I’m glad you are able to create things like this!

@purujit.saha I’ve got a PR coming your way for a Readme fix.

I’m trying to get this to work, but, the canvas seems to be cut off with a lot of different categories. How can I increase the viewable canvas to see the whole diagram?

Appreciate your work on this so far!

I just tried to install this but I have Google Advanced Protection so this was blocked. Is there any way to make this work in that environment? Thanks!