Public
Edited
Jul 14, 2020
18 forks
187 stars
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
Insert cell
Insert cell
Insert cell
formatPercentChange = d3.format("+.1%")
Insert cell
formatRatio = {
const format = d3.format(".2~r");
return x => format(x) + "×";
}
Insert cell
color3a = {
const values = [...deaths.values()];
return d3.scaleLinear()
.domain([d3.min(values, ([a, b]) => (b - a) / a), 0, d3.max(values, ([a, b]) => (b - a) / a)])
.range([-1, 0, 1])
.interpolate((a, b) => a < 0
? t => d3.interpolateBlues(1 - t)
: t => d3.interpolateReds(t));
}
Insert cell
color3b = {
const values = [...deaths.values()];
const max = Math.max(-d3.min(values, ([a, b]) => (b - a) / a), d3.max(values, ([a, b]) => (b - a) / a));
return d3.scaleLinear()
.domain([-max, 0, max])
.range([-1, 0, 1])
.interpolate((a, b) => a < 0
? t => d3.interpolateBlues(1 - t)
: t => d3.interpolateReds(t));
}
Insert cell
color4 = {
const values = [...deaths.values()];
const max = Math.max(d3.max(values, ([a, b]) => a / b), d3.max(values, ([a, b]) => b / a));
return d3.scaleLog()
.domain([1 / max, 1, max])
.range([-1, 0, 1])
.interpolate((a, b) => a < 0
? t => d3.interpolateBlues(1 - t)
: t => d3.interpolateReds(t));
}
Insert cell
import {
map,
legend,
names,
deaths,
format,
formatChange,
color,
color2,
d3
} from "@mbostock/mortality-due-to-alcohol-use-disorder"
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more