This can be accomplished with D3.js[1] to bind data to HTML elements -- a div block, in your case -- and color them based on value.
D3 is a big library, so you'll likely only need these modules:
d3-selection
d3-scale
[1]: https://d3js.org/