Published
Edited
Jan 5, 2021
5 forks
9 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = {
const data = [];
let week = 0;
// We divide by 2 because it's two shots
for (let vax = 0; vax <= pop; vax += vaxPerWeek / 2){
data.push({
week,
vax
});
week++;
}
return data;
}
Insert cell
weekCrossed = data.find(d => d.vax >= hit);
Insert cell
pop = 330e6 // U.S. population is about 330 million. Try changing this value to your country's population!
Insert cell
hit = pop * (herdImmunityThreshold / 100)
Insert cell
Insert cell
line = d3.line()
.curve(d3.curveStepAfter)
.x(d => xScale(d.week))
.y(d => yScale(d.vax));
Insert cell
xScale = d3.scaleLinear()
.domain(d3.extent(data, d => d.week))
// .domain([0, Math.max(104, d3.max(data, d => d.week))])
.range([0, chartWidth]);
Insert cell
yScale = d3.scaleLinear()
.domain([0, pop])
.range([chartHeight, 0]);
Insert cell
Insert cell
margin = ({left: 35, right: 10, top: 26, bottom: 42});
Insert cell
chartWidth = width - margin.left - margin.right;
Insert cell
chartHeight = {
const min = 400, max = 500;
return Math.max(Math.min(width * 9 / 16, max), min) - margin.top - margin.bottom;
}
Insert cell
Insert cell
d3 = require("d3@6")
Insert cell
geometric = require("geometric@2")
Insert cell
import { slider } from "@jashkenas/inputs"
Insert cell
import {tweet} from "@mbostock/tweet"
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