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

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