I\'m using some code from d3.js to build a cell sheet in an html page dynamically. So if it is a 5x5 .csv report, it will produce 5x5 on the page and so forth.
This repo
You should be able to just append a .style after your last .text(). It will be something along the lines of:
.append('td')
.text(...)
.style('background-color', function(d) {
if (d < 3) {return 'green';}
else if (d < 5) {return 'yellow';}
else if (d < 10) {return 'orange';}
else {return 'red';}
};
Might take a bit of fiddling around with the return values for the colours, not sure whether returning strings will work, might be better to return rgb(...) colours instead.