Published
Edited
Apr 23, 2020
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
dist = (array, scale) => {
const stdev = scale || Math.sqrt(d3.variance(array));
const mean = d3.mean(array);
const x = x => (50 * (x - mean)) / stdev;
return html`<span style="position: relative;">
${mean.toFixed(0)}${array.map(
(d, i) =>
html`<span style="
position: absolute;
top: ${x(d)}px;
left: ${x(d)}px;
opacity: .3;
z-index: -1;
">
${d}
</span>`
)}</span>`;
}
Insert cell
data = Array.from(
getCovidDataGrouped({
statistic: "positive",
derivative: 1
}).entries()
)
.map(([state, map]) => ({
state,
name: stateNames.get(state),
data: Array.from(map.entries())
.map(([date, value]) => value)
.filter(value => value !== undefined)
}))
.sort((a, b) => a.name.localeCompare(b.name))
Insert cell
scale = d3.mean(data.map(({ data }) => d3.deviation(data)))
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