Let's create a scale that maps the count property of each element in data to a visual height for the corresponding bar. We'll use a linear scale. Remember to map HEIGHT of the graph to a very low data point and the top of the graph (0 in the range) map to a very high data value. Add this code to the bottom of the AJAX callback:
var yScale = d3.scaleLinear();
yScale.range([HEIGHT, 0]);
var yMin = d3.min(data, function(datum, index){
return datum.count;
})
var yMax = d3.max(data, function(datum, index){
return datum.count;
})
yScale.domain([yMin, yMax]);
We could use d3.extent, but we're going to need the individual min values later on. Immediately after the previous code, let's tell D3 to adjust ...