Public
Edited
Apr 7
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
choropleth2 = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);


svg.append("g")
.attr("transform", "translate(300,20)")
.append(() =>
legend({
color: ordinalcolor,
title: data.title,
width: 450,
tickFormat: "0.1f"
})
);

svg.append("g")
.selectAll("path")
.data(counties.features)
.join("path")
.attr("stroke", "black")
.attr("stroke-linejoin", "bevel")
.attr("stroke-width", 0.2)
// .attr("fill", function(d){
// console.log(color(data.get(d.properties.FIPS)[0]))
// return color(data.get(d.properties.FIPS)[0]);
// })
.attr("fill", function(d){
if(ordinaldata.get(+d.properties.STCOFIPS) > 0){
return ordinalcolor(ordinaldata.get(d.properties.STCOFIPS));
}
else{
return nancolor;
}
})
.attr("fill", d => ordinalcolor(ordinaldata.get(+d.properties.STCOFIPS)))
.attr("d", path)
.append("title")
.text(d => " Risk Rating: " + ordinaldata.get(+d.properties.STCOFIPS));

return svg.node();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chart(numericSort(risk), jenks)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
csv_dataOrdinal = d3.csvParse(await FileAttachment("National_Risk_Index_Counties_807384124455672111-3 (2)-1-3@1.csv").text(),({STCOFIPS, Rating}) => [+STCOFIPS, Rating])
Insert cell
Insert cell
ordinaldata = Object.assign(new Map(csv_dataOrdinal), {title: "Assessing Wildfire Risk by County, Ordinal"})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
colors = d3.scaleThreshold()
.domain(pnaturalbreaks)
.range(PuPi)
Insert cell
ordinalcolor = d3.scaleOrdinal()
.domain (["Very Low", "Relatively Low", "Relatively Moderate", "Relatively High", "Very High"])
.range (["#fee5d9", "#fcae91", "#fb6a4a", "#de2d26", "#a50f15"]);
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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