Public
Edited
Oct 21, 2022
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
summaryData
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
Insert cell
{
const plotData = summaryData
.filter((d) => d.location == "Portugal")[0]
.items.filter((d) => d.date >= "2021-06-01");

//return plotData;
return Plot.plot({
marginLeft: 100,
marginRight: 100,
y: { type: "linear" },
marks: [
Plot.lineY(
plotData,
Plot.windowY({
k: 28,
//reduce: "avg",
x: (d) => new Date(d["date"]),
y: "weekly_icu_admissions"
})
),
Plot.text(
plotData,
Plot.selectLast(
Plot.window({
k: 28,
//reduce: "avg",
x: (d) => new Date(d["date"]),
y: "weekly_icu_admissions",
text: (d) => "new_deaths"
})
)
)
]
});
}
Insert cell
Insert cell
summaryData
Insert cell
plotData = summaryData
.map((d) => d.record_current)
.filter((d) => d && d.continent.match(/Europe/))
Insert cell
Insert cell
Insert cell
Insert cell
dataPT = d3.csv(
"https://raw.githubusercontent.com/covid19-eu-zh/covid19-eu-data/master/dataset/covid-19-pt.csv"
)
Insert cell
rollsum = Plot.window({ k: 14, anchor: "end", reduce: "mean" })
Insert cell
fromDate = "2022-06-01"
Insert cell
Insert cell
Insert cell
dataRecentGrowth = {
const plotData = _.chain(summaryData)
.map((d) => {
d.growth =
d.record_1weekAgo &&
+d.record_current.new_cases_smoothed_per_million /
+d.record_1weekAgo.new_cases_smoothed_per_million;

return d;
})
.filter(
(d) =>
+d.record_current.new_cases_smoothed_per_million > 500 &&
d.population > 1000000 &&
d.growth > 1.3
)
.sortBy((d) => -d.growth)

.value(); //d.record_current.new_cases_smoothed_per_million


return plotData;
return Plot.plot({
marginLeft: 100,
marginRight: 100,
marks: [
Plot.lineY(
plotData,
Plot.map(
{ y: rollsum },
{
x: (d) => new Date(d["date"]),
y: "new_deaths",
interval: d3.utcDay,
stroke: "lightgrey"
}
)
),
Plot.text(
plotData,
Plot.selectLast(
Plot.map(
{ y: rollsum, text: rollsum },
{
x: (d) => new Date(d["date"]),
y: "new_deaths",
text: (d) => `${d["new_deaths"]}`,
textAnchor: "start",
frameAnchor: "bottom",
dy: -3
}
)
)
),
Plot.ruleY([0])
]
});
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const data = _.chain(targetData)
.filter((d) => selectedCountries.includes(d.location))
.map((d) => d.items)
.flatten()
.filter((d) => d.date >= "2022-08-22")

.value();

const maxDate = _.chain(data)
.map((d) => d.date)
.max()
.value();

return maxDate;
}
Insert cell
targetData
Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

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
Insert cell
Insert cell
style_bootstrap
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
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
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
es_ES = ({
decimal: ",",
thousands: ".",
grouping: [3],
currency: ["$", ""],
dateTime: "%a %b %e %X %Y",
date: "%d/%m/%Y",
time: "%H:%M:%S",
periods: ["AM", "PM"],
days: [
"Domingo",
"Lunes",
"Martes",
"Miércoles",
"Jueves",
"Viernes",
"Sábado"
],
shortDays: ["Dom", "Lun", "Mar", "Mi", "Jue", "Vie", "Sab"],
months: [
"Enero",
"Febrero",
"Marzo",
"Abril",
"Mayo",
"Junio",
"Julio",
"Agosto",
"Septiembre",
"Octubre",
"Noviembre",
"Diciembre"
],
shortMonths: [
"Ene",
"Feb",
"Mar",
"Abr",
"May",
"Jun",
"Jul",
"Ago",
"Sep",
"Oct",
"Nov",
"Dic"
]
})
Insert cell
Insert cell
Insert cell
Insert cell
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