Right now, the bars are black. A linear scale will interpolate between colors, just like a regular number. Add the following to the end of the AJAX callback:
var yDomain = d3.extent(data, function(datum, index){
return datum.count;
})
var colorScale = d3.scaleLinear();
colorScale.domain(yDomain)
colorScale.range(['#00cc00', 'blue'])
d3.selectAll('rect')
.attr('fill', function(datum, index){
return colorScale(datum.count)
})
Notice that we calculate they Domain using d3.extent so that the real minimum of the data set is used to map #00cc00:
![](https://static.packt-cdn.com/products/9781789342383/graphics/assets/df8c385d-d6d3-4b4e-ac5c-f5967e8fbcf9.png)