Published
Edited
Dec 20, 2021
1 star
Plot: A few custom time axesAccess to Family planningPlot: MarimekkoAutoplot matrixWhat do people buy on Bandcamp?Plot: colorContrast transformA Timeline of Democratic Presidential CandidatesPlot: Diverging stacked barsPlot: Horizon ChartPlot: Ridgeline PlotTwo-Tone Pseudo Color Scales with Observable Plot & Vega-LiteRecreating Östling’s regression visualizationsError barsPlot: regressionSkies PlotHorizon graph & Barcode with PlotTemporal AliasingPlot for mathematiciansPlot Isotype dot plotCOVID-19 Netherlands Reproduction Number TutorialPlot Mountain SunsetSpine chartsGreenhouse gas emission projectionsRaincloud Plots with Observable PlotUpset Plots with Observable PlotExploring CIELChab
Nature variant waves graphic
When Presidents Fade AwayThe Coronavirus landscapeOur World In Data charts visualisationThe normal modelVisualizing The New York Times’s Mini CrosswordDistributions and summary statistics - a collection of Plot examplesVariants of SARS-Cov-2 in EuropeLaid off: 6 million jobs and countingConcentration values vs. TimeTopological subsamplingPlot of plotsCyclical time scale, v2Bullet graph IIPlot: Bullet graphCyclical time scaleRoad traffic under COVID restrictions (France)K-means binningMatrix diagramELD ViewerHappy anniversary, Project Gutenberg!ROC curvePlot stargazer historyPlot HyperboloidPhone bar plotsLog-scale histogramDatabase Outage PlotBertin’s hotelIreland’s top trade partnersBump chartBubble MatrixRenko ChartGitHub BurndownPlot: Grid choroplethCandlestick Chart
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
json_from_github = d3.json(
"https://raw.githubusercontent.com/hodcroftlab/covariants/master/web/data/perCountryData.json"
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mapper = (d) => {
/* Provide a count for each of the five variants we are interested in and other */
let { cluster_counts, week, total_sequences } = d;

let myObject = {};
myObject.week = week;

let total_counted = Object.values(cluster_counts).reduce(
(previousValue, currentValue) => {
return previousValue + currentValue;
},
0
);

let counts = {};

counts.alpha = 0;
counts.beta = 0;
counts.gamma = 0;
counts.delta = 0;
counts.omicron = 0;
counts.other = total_sequences - total_counted;

Object.keys(cluster_counts).forEach((key) => {
switch (key) {
case "20I (Alpha, V1)":
counts.alpha += cluster_counts[key];
break;
case "20H (Beta, V2)":
counts.beta += cluster_counts[key];
break;
case "20J (Gamma, V3)":
counts.gamma += cluster_counts[key];
break;
case "21A (Delta)":
case "21I (Delta)":
case "21J (Delta)":
counts.delta += cluster_counts[key];
break;
case "21K (Omicron)":
counts.omicron += cluster_counts[key];
default:
counts.other += cluster_counts[key];
}
});

myObject.counts = counts;

return myObject;
}
Insert cell
reducer = (previousValue, currentValue) => {
/* Create a flat array of objects, each containing variant, count and week values */
let { week, counts } = currentValue;

Object.keys(counts).forEach((key) => {
let myObject = {};
myObject.variant = key;
myObject.count = counts[key];
myObject.week = new Date(week);

previousValue.push(myObject);
});

return previousValue;
}
Insert cell
Insert cell
Insert cell
import { swatches as Swatches } from "@d3/color-legend"
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