Roadmapper migration my objective is to make the structure as much like the VBA version as possible so as to make dual maintenance a possibility.
Here is the result of applying various color ramps to a few lines of a Google Spreadsheet.
Copy of heatMap
This code produces the example above. To test it, go to the spreadsheet and press the button.
The main points here are
This is all that's needed. The color ramp and caching utilities are provided in the mcpher script library.
This second example, which also demonstrates the use of sheet caching, creates a random table of numbers then successively applies different heatmap entries to the output, taking a pause between each one. To test it, go to the random tab of the spreadsheet and press the button. Here's the code
One of the problems with a heatmap is that your font color may need to be changed so that it is visible against the chosen color. In fact there are W3 org guidelines for contrast. I apply that algorithm to decide whether to use black or white for the text color. I initially played around with contrasting using HSL and so on, but certain color combinations were just plain ugly, so settled for flipping between black and white. Here's the whole section, where a ramp fill color is calculated, and then we use the calculated text color, based on the luminance of the fill color.
The code for that is here.
The idea here is that you create your own entries as you find useful color ramps. Here are the predefined ones, some of which are used above
For more like this, see From VBA to Google Apps Script .
For help and more information join our forum,follow the blog or follow me on twitter .
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > From VBA to Google Apps Script > Google Script Color Ramp >