Published
Edited
Jul 13, 2020
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
chart
Insert cell
chart.signal('indexDate', timerange[0]+20*86400000).run()
Insert cell
{
const frame = (gif, t) => {
if (t<timerange[1]) {
chart.signal('indexDate', t)
chart.toCanvas().then(r=>{
gif.addFrame(r);
requestAnimationFrame(()=>{
frame(gif, t+86400000);
});
});
} else {
gif.render();
}
};
const div = document.createElement('div');
let downloadButton;
const button = document.createElement('button');
button.onclick = ()=> {
if (downloadButton) {
div.removeChild(downloadButton);
downloadButton = null;
}
const gif = new GIF();
gif.on("finished", blob => {
downloadButton = DOM.download(blob);
div.appendChild(downloadButton);
});
frame(gif, timerange[0]);
}
button.innerText = 'start gif creation - (click, then wait for "Save" button)';
div.appendChild(button);
return div;
}
Insert cell
Insert cell
Insert cell
inputData.filter((x)=>{return (x.ValueType=='Tests')}).filter((x)=>{return (x.Value>0)})
Insert cell
timerange = d3.extent( inputData.map(ele=>Date.parse(ele.Date)))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
MeasureLabels = ["Positives", "Deaths", "Tests", "Hospitalized", "Daily Positive %"]
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
cellD = new Cell(grid.querySelector("[name=d]"))
Insert cell
cellC = new Cell(grid.querySelector("[name=c]"))
Insert cell
cellB = new Cell(grid.querySelector("[name=b]"))
Insert cell
cellA = new Cell(grid.querySelector("[name=a]"))
Insert cell
cellE = new Cell(grid.querySelector("[name=e]"))
Insert cell
cellF = new Cell(grid.querySelector("[name=f]"))
Insert cell
cellF.embed(r6)
Insert cell
cellD.embed(instructions)
Insert cell
cellG = new Cell(grid.querySelector("[name=g]"))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dd2.firstChild.firstChild.style.fontSize = "1.2rem"
Insert cell
Insert cell
Insert cell
Insert cell
r4.firstChild.firstChild.style.fontSize = "1.2rem"
Insert cell
Insert cell
Insert cell
md `
### radiobutton for cumulative vs daily place in grid at top`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
r5 = radio({
title: 'Align to First Case',
options: [
{ label: 'Days since first 20 cases', value: 'Align' },
{ label: 'Absolute Date', value: 'Absolute' },
],
value: 'Absolute'
})
Insert cell
r6 = radio({
title: 'Include US',
options: [
{ label: 'Include Totals for US', value: 'USTotal' },
{ label: 'Exclude Totals for US', value: 'USExcluce' },
],
value: 'USTotal'
})
Insert cell
cellG.embed(r5)
Insert cell
plotAlignment = Generators.input(r5)
Insert cell
plotAlign = (plotAlignment=='Absolute' ? false : true)
Insert cell
cellE.embed(r4)
Insert cell
plotType = Generators.input(r2)
Insert cell
plotMeasure = Generators.input(dd2)
Insert cell
plotAggregate = Generators.input(r3)
Insert cell
plotDaily = Generators.input(r4)
Insert cell
plotUs = Generators.input(r6)
Insert cell
Insert cell
import {GIF} from '@mbostock/canvas-to-gif'
Insert cell
chart
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