Public
Edited
Jul 14, 2020
18 forks
186 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

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