Given the image looks more like a table and that you can give every cell in a table a CSS class here's something I would try. It looks good in theory and should work.
The example at
https://developers.google.com/chart/interactive/docs/examples#custom_table_example gets the classname for the cell from the data but there's no reason you can't step through the dataTable do some sort of logical test on the data and set a classname programmatically. You could even create an array of colors, do the logical test, set the classname and then use IF, SWITCH or a MAP to set the background color from the color array.
If you wanted you can either add new columns to the dataTable that has empty data so the original data that you did the test on doesn't show or even reset the cell's contents to an empty string. Something to start with:
var totalRows = mydata.getNumberOfRows();
var totalCols = mydata.getNumberOfColumns();
for (i = 0; i < totalRows; i++) {
for (j = 0; j < totalCols; j++) {
// logical test, create myclass as the classname
mydata.setProperty(i,j,"className",myclass);
mydata.setFormattedValue(i,j,"");
}
}