Published
Edited
Apr 13, 2020
Insert cell
Insert cell
viewof line = vl.markLine()
.width(750)
.height(400)
.data(all)
.encode(
vl.x().fieldQ("index").axis({ title: 'Days since Countries Patient Zero' }),
vl.y().fieldQ("Cases").axis({ title: 'Deaths' }),
vl.color().fieldN("Country")
)
.render()
Insert cell
liveDataUK = (await fetch("https://api.covid19api.com/total/dayone/country/united-kingdom/status/deaths")).json();
Insert cell
liveDataItaly = (await fetch("https://api.covid19api.com/total/dayone/country/italy/status/deaths")).json();
Insert cell
liveDataSpain = (await fetch("https://api.covid19api.com/total/dayone/country/spain/status/deaths")).json();

Insert cell
liveDataChina = (await fetch("https://api.covid19api.com/total/dayone/country/china/status/deaths")).json();

Insert cell
liveDataUsa = (await fetch("https://api.covid19api.com/total/dayone/country/us/status/deaths")).json();

Insert cell
Insert cell
liveDataItalyIndexed = (() => {
let x = 1;
liveDataItaly.map((item) => {item.index = x; x++; return item;})
return liveDataItaly;
})();
Insert cell
liveDataChinaIndexed = (() => {
let x = 1;
liveDataChina.map((item) => {item.index = x; x++; return item;})
return liveDataChina;
})();
Insert cell
liveDataSpainIndexed = (() => {
let x = 1;
liveDataSpain.map((item) => {item.index = x; x++; return item;})
return liveDataSpain;
})();
Insert cell
liveDataUKIndexed = (() => {
let x = 1;
liveDataUK.map((item) => {item.index = x; x++; return item;})
return liveDataUK;
})();
Insert cell
liveDataUsaIndexed = (() => {
let x = 1;
liveDataUsa.map((item) => {item.index = x; x++; return item;})
return liveDataUsa;
})();
Insert cell
all = (liveDataUKIndexed.concat(liveDataSpainIndexed, liveDataUsaIndexed, liveDataItalyIndexed, liveDataChina)).sort((a, b) => new Date(a.Date) - new Date(b.Date))
Insert cell
import {vl} from '@vega/vega-lite-api';


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