Published
Edited
Nov 15, 2020
2 forks
6 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mapSvgWithIds = {
const map = d3.select(mapSvgOriginal.cloneNode(true));
const statesGroup = map.select("g.states");
const statesPaths = statesGroup.selectAll("path");

statesPaths.each(function(_d, i) {
const pathEl = d3.select(this);
const [stateClassName] = pathEl.attr("class").split(" ");
const stateNameId = stateClassName
.replace("state-", "")
.replace(/-/gi, " ");
pathEl.attr("data-id", stateNameId);
pathEl.attr("class", null);
pathEl.attr("fill", null);
});

map.selectAll("text").each(function(_d, i) {
d3.select(this).attr("data-id", textData[i]);
});

return map.node();
}
Insert cell
Insert cell
Insert cell
Insert cell
mapObesity = {
const map = d3.select(mapSvgWithIds.cloneNode(true));
map
.selectAll("path")
.data(data, function(d) {
return d ? d.locationdesc : this.dataset.id;
})
.attr("fill", d => color(d["White, non-Hispanic"]))
.attr("stroke", "#e2e2e2");

return map.node();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { legend } from "@d3/color-legend"
Insert cell
import { pivotByRaceData } from "@clhenrick/het-data-intake-u-s-chronic-disease-indicators-cdi-brfss"
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