Atma Atma - 5 months ago 30x
Javascript Question

how to change colors of cells in google visualization graph table

I am building a table in google graphs. I would like to change the color of a cell based on the numeric value of a cell. I am assuming I will do something like iterate through all of the cells and call the colorFormat object specified in docs here:

The problem is that there are no examples of exactly how to implement this method.

Does anyone know of an example or how the colorFormat can be implemented to change the color of cells?


Answer - did you scroll farther down?

var formatter = new google.visualization.ColorFormat();
formatter.addRange(-20000, 0, 'white', 'orange');
formatter.addRange(20000, null, 'red', '#33ff33');
formatter.format(data, 1); // Apply formatter to second column