Public
Edited
Apr 6
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof bins = Inputs.range([0, 600], {step: 10, label: "Bins"})
Insert cell
Plot.plot({
marks: [
Plot.rectY(csv_data_objects, Plot.binX({y: "count"}, {x: "Index", thresholds: bins})),
Plot.ruleY([0])
]
})
Insert cell
showScaleGrouping(risk, {jenks})
Insert cell
chart(numericSort(risk), jenks)
Insert cell
Insert cell
d3 = require("d3@5")
Insert cell
import {legend} from "@d3/color-legend"
Insert cell
simple = require("simple-statistics@7.0.7/dist/simple-statistics.min.js")
Insert cell
format = d => `${d}%`
Insert cell
topojson = require("topojson-client@3")
Insert cell
US = FileAttachment("dtl_main.json").json()
Insert cell
counties = topojson.feature(US, US.objects.dtl_main)
Insert cell
csv_data = d3.csvParse(await FileAttachment("National_Risk_Index_Counties_807384124455672111-3 (2)-1.csv").text(),({FIPS, Index}) => [+FIPS, +Index])
Insert cell
csv_data_objects = Object.assign((d3.csvParse(await FileAttachment("National_Risk_Index_Counties_807384124455672111-3 (2)-1.csv").text(), d3.autoType)).map(({FIPS, Index}) => ({FIPS: +FIPS, Index: +Index})))
Insert cell
data = Object.assign(new Map(csv_data), {title: "Assessing Wildfire Risk by County"})
Insert cell
risk = Array.from(csv_data.values(), d => d[1])
Insert cell
YlOgRd = [d3.color("#ffffb2"), d3.color("#fecc5c"), d3.color("#fd8d3c"), d3.color("#f03b20"),d3.color("#bd0026")]
Insert cell
nancolor = d3.color("black")
Insert cell
nullcolorforlegend = d3.scaleOrdinal()
.domain([NaN])
.range([nancolor])
Insert cell
naturalbreaks = simple.ckmeans(risk, YlOgRd.length).map(v => v.pop())
Insert cell
//Display the Histogram and DOT plot
Insert cell
color = d3.scaleThreshold()
.domain(naturalbreaks)
.range(YlOgRd)
Insert cell
width = 975
Insert cell
height = 610
Insert cell
margin = 500
Insert cell
//projection = d3.geoAlbers().fitExtent([[margin, margin], [width - margin, height - margin]], counties)
Insert cell
projection = d3.geoAlbers().rotate([94,0]).fitExtent([[80, 80], [width, height]], counties);
Insert cell
path = d3.geoPath().projection(projection);
Insert cell
// Explain the variable and assess the distribution
Insert cell
jenks = d3
.scaleThreshold()
.domain(naturalbreaks)
.range(["#ffffb2", "#fecc5c", "#fd8d3c", "#f03b20", "#bd0026"])
Insert cell
data.get(1001)
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