- Use data from 50 cities
- Adapt program to handle large datasets by using variables instead of numbers
When you run your application, the first circle is black with no label. This section fixes the problem.
adjust text element above the main update loop
Change first temperature and city values to first elements of array
.text(temperatureData[0].city +
" temperature: " +
temperatureData[0].lowTemp );
svg.append("circle")
.attr("cx", width/2)
.attr("cy", height/2)
.attr("r", circleSizeScale(temperatureData[0].lowTemp))
.attr("fill", colorScale(temperatureData[0].lowTemp)
);
As you used the data from array[0], you now have to set the index set to 1. You just used the element at index 0 in the code section above.
Use d3.min and d3.max to replace [27, 49]
-
set a variable for minTemperature
-
use the d3 method
d3.min->d3.min(array, callback-function(d)to find the lowest temperature -
repeat the steps above for maxTemperature using
d3.maxvar minTemperature = d3.min(temperatureData, function(d){ return d.lowTemp; }); var maxTemperature = d3.max(temperatureData, function(d){ return d.lowTemp; });