Inherit link colors from cells – D3 sankey from Excel

We had a question on our forum the other day about whether it would be possible to inherit the cell colors from the color of the originating cells in Excel in the d3.js Sankey diagram created directly from Excel data.

The answer is of course, yes. As usual the parameter sheet controls the options.

The new options are

  • InheritNodeColor – if yes, the the color of the nodes will match the background color of the cells of the source or targetIDs as appropriate.
  • InheritLinkColor – if yes, the color of the link will match the background color of the value that gives it its width
  • linkOpacity. This has a default value of .2, and as you hover over a link it darkens. If you specify any value in here, the hover feature will not work (its a long story). Setting it to 1 will cause the inheritLinkColor to be fully saturated. Any value between 0 and 1 will progressively darken the color.
Here’s an example of a chart with fully saturated links (linkOpacity 1)

and for the browser challenged, a picture of it

 

Here’s the input data that created this. I applied a heatmap to the data to get the coloring


 

See more stuff like this and download the code for this in the cDataSet.xlsm workbook on the Excel Liberation site.

About brucemcp 225 Articles
I am a Google Developer Expert and decided to investigate Google Apps Script in my spare time. The more I investigated the more content I created so this site is extremely rich. Now, in 2019, a lot of things have disappeared or don’t work anymore due to Google having retired some stuff. I am however leaving things as is and where I came across some deprecated stuff, I have indicated it. I decided to write a book about it and to also create videos to teach developers who want to learn Google Apps Script. If you find the material contained in this site useful, you can support me by buying my books and or videos.