To create my colors, I went onto ColorBrewer.org. and choose a multi-hue color scheme going from light green to blue. I then wrote in the code (whatever the color name is) = and I pasted the HEX color code and repeated for each color I wanted to create the variable. To use the colors in the unclassed and classed maps, I replaced the color names in the range with my colors (lightgreen,green,blue) to use the variables I created before. Make sure to put the colors in the order that you want them to be associated with the numbers in the domain.
I created an unclassed map by using the raw data and mapping it in color. Using the extent function found the min and max of the percent of children under the age of 5 so it associates the min percentage with white and then up to the max percentage with dark blue and uses a continuous color scheme from white to dark blue. scaleLinear inputs of values and colors and maps them to each other using the linear formula y=mx+b.
To complete the threshold classification, I used the min and max values to decide where to start and end the classification. Then I looked into the areas that had differences in frequency. I decided to go with 5, 6, 6.5, 7.5, and 10.6 to encapsulate the most frequent numbers. The colors then divide the data depending on how many colors there are. scaleThreshold maps continuous numeric input values into discrete output values based on specified threshold boundaries.
scaleQuantile classification breaks up groups evenly and continuously then associates them with corresponding color increasing percentage from white to dark blue. It breaks up the data in groups depending on how many colors are given. I gave six colors so the data was split into six equal groups so there are about 18 counties per color.
I chose six classes because the (max value - min value) / the interval = 6.27 which would give us six bins to divide the data between.
scaleThreshold uses the continuous data and lets us choose where we want the breaks. By using domain(naturalbreaks) it groups the data by splits in the histogram. I changed the ckmeans to be (childpct,6) to tell it I want 6 groups from the data. The number of data points in each group are not the same.
For the color scheme, I went to color brewer and chose a scheme with six colors and copied the HEX code into the range in order from lightest color to darkest color to correspond with the natural breaks data.
Equal Intervals scaleQuantize spilts the continuous data by making the intervals between the bins the same amount. Each bin should have a difference of about 1%. Since there is a lot of counties with about 5% of population under 5, the second bin/color has the most boxes. The d3.extent find the min and max of the data and then splits it into equal intervals.
This histogram is skewed to the right with an outlier at 10.6. The histogram shows the frequency of different percentage intervals by .5%. I believe that natural breaks would be the most appropriate classification since the data is skewed and there is an outlier. I think that Quantile classification would also work here with the skewed data. There is a high concentration of values between 5 and 7 percent which means that most counties have about 6% of their population under 5 years old.
This line defines the variable nebraska to a FileAttachment object that opens the nebraska_counties_wgs82 json. This file contains the polygon information to draw the counties of nebraska.
This line parses the NebraskaPop.csv, creating a new table of the format: FIPS -> [percent under the age of 5] and creates the percentage variable with each county.