Link to my project:
My problem:
So far, this is as close as I can get to different colors appearing in different threads, but they are going “in order” of color rather than in order of the temperature data.
I know this is in part related to the fact that I put year data in the scaleThreshold rather than temperature data
// make legendScale - helps to determine color of cell
let temperatures = data.map(d => d.temperature)
let legendThreshold = d3
.scaleThreshold()
.domain(ticks)
.range(['#13315C', '#134074', '#06AED5', '#FFE156', '#E8C547', '#FAA916', '#FF4B1A', '#FF3A24', '#FF1F2E', '#DF2935']);
But if I try to use the temperature data (or any other data), my heat map becomes just one color.
I found a S.O. question that suggests it is because the arrays used in my domain and range do not have a length that are 1 apart from each other (i.e. length of 13 and 14).
If I test that out, like so…
let temperatures = data.map(d => d.temperature)
let legendThreshold = d3
.scaleThreshold()
.domain([1, 2, 3, 4, 5, 6, 7, 8, 9])
.range(['#13315C', '#134074', '#06AED5', '#FFE156', '#E8C547', '#FAA916', '#FF4B1A', '#FF3A24', '#FF1F2E', '#DF2935']);
I get the same results as the one big red heat map from above.
I feel like I am missing some fundamental understanding about d3 that is affecting how I am approaching this problem. What am I missing here?
Thank you.
Browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15
Challenge: Visualize Data with a Heat Map
Link to the challenge: