Published
Edited
Oct 29, 2020
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
bin = d3.bin().value(d => d[VARS.RPL_SUM])
Insert cell
bucketRPLThemesSum = bin(dataWithRPLThemes)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dataWithRPLThemes = data.filter(d => d[VARS.RANK_TOTAL] !== -999)
Insert cell
Insert cell
VARS = ({
RANK_TOTAL: "RPL_THEMES", // combined rank for all 4 themes
RPL_SUM: "SPL_THEMES" // sum of series for all 4 themes
})
Insert cell
numberRows = data.length
Insert cell
columnNames = Object.keys(dataWithRPLThemes[0])
Insert cell
Insert cell
Insert cell
dataName = "CDC Social Vulnerability Index"
Insert cell
Insert cell
dataPublisher = "Centers for Disease Control and Prevention/ Agency for Toxic Substances and Disease Registry/ Geospatial Research, Analysis, and Services Program. CDC Social Vulnerability Index 2018 Database US. https://www.atsdr.cdc.gov/placeandhealth/svi/data_documentation_download.html. Accessed on 10/28/2020."
Insert cell
Insert cell
dataProvider = "N/A"
Insert cell
Insert cell
dataDescription = md`See [dataset documentation page](https://www.atsdr.cdc.gov/placeandhealth/svi/documentation/SVI_documentation_2018.html)`
Insert cell
Insert cell
dataUrl = "https://www.atsdr.cdc.gov/placeandhealth/svi/data_documentation_download.html"
Insert cell
Insert cell
dataIsPublic = true
Insert cell
Insert cell
historical = true
Insert cell
Insert cell
temporal = Boolean(dataStartDate && dataEndDate)
Insert cell
Insert cell
dataStartDate = undefined
Insert cell
Insert cell
dataEndDate = undefined
Insert cell
Insert cell
geoCovered = "United States and Puerto Rico"
Insert cell
Insert cell
geoDimensions = ["county", "census tract"]
Insert cell
Insert cell
geoDimensionsForm = ["FIPS"]
Insert cell
Insert cell
dataFormats = ["CSV", "Shapefile"]
Insert cell
Insert cell
noDataCode = "-999"
Insert cell
Insert cell
hasAPI = dataApiUrl.length > 0
Insert cell
Insert cell
dataApiUrl = ""
Insert cell
Insert cell
dataLicense = "Public Domain"
Insert cell
Insert cell
dataFileAttachment = FileAttachment("SVI2018_US_COUNTY.csv")
Insert cell
Insert cell
dataFileAttachmentDate = new Date("2020-10-28")
Insert cell
Insert cell
Insert cell
Insert cell
getSummaryStats = (data, field) => ({
min: d3.min(data, d => d[field]),
max: d3.max(data, d => d[field]),
median: d3.median(data, d => d[field]),
mean: d3.mean(data, d => d[field])
})
Insert cell
format2d = d3.format(".2f")
Insert cell
data = {
if (hasAPI && dataApiUrl) {
return fetch(dataApiUrl).then(res => {
if (res.ok) return res.json();
return res;
});
}

if (dataFileAttachment) {
return await dataFileAttachment.csv({ typed: true }); // <- change `.csv()` if the data is in another format, e.g. JSON
}
}
Insert cell
sampleDatum = {
anotherSampleDatum;
const d = getSampleDatum();
return d;
}
Insert cell
getSampleDatum = () =>
data ? data[Math.floor(Math.random() * data.length)] : undefined
Insert cell
Insert cell
import { button } from "@jashkenas/inputs"
Insert cell
import { toc } from "@mbostock/toc"
Insert cell
d3 = require("d3@6")
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