Public
Edited
May 2
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
format = d => `${d}%`
Insert cell
Insert cell
brevard = FileAttachment("BrevardBlocks.json").json()
Insert cell
block_features = topojson.feature(brevard, brevard.objects.BrevardBlocks)
Insert cell
csv_data = d3.csvParse(await FileAttachment("BrevardCensusData.csv").text(),({BLOCKA, TotalPop, Hispanic}) => [+BLOCKA, +Hispanic/TotalPop])
Insert cell
data = Object.assign(new Map(csv_data), {title: "% Hispanic By Block"})
Insert cell
his_rate = Array.from(csv_data.values(), d => d[1])
Insert cell
YlGnBu = [d3.color("#edf8e9"), d3.color("#bae4b3"), d3.color("#74c476"), d3.color("#31a354"),d3.color("#006d2c")]
Insert cell
clean_rates = his_rate.filter(d => typeof d === "number" && !isNaN(d)); // get rid of the nulls (blocks with no residents)
Insert cell
naturalbreaks = simple.ckmeans(clean_rates, YlGnBu.length).map(v => v.pop()) // visualize blocks with values
Insert cell
color = d3.scaleThreshold()
.domain(naturalbreaks)
.range(YlGnBu)
Insert cell
width = 975
Insert cell
height = 900
Insert cell
margin = 30
Insert cell
projection = d3.geoAlbers().fitExtent([[margin, margin], [width - margin, height - margin]], block_features)
Insert cell
//Using a path generator to project geometry onto the map
path = d3.geoPath().projection(projection);
Insert cell
data.get(1078)
Insert cell
color(data.get(1078))
Insert cell
color(40)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more