Public
Edited
Oct 22, 2022
1 fork
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
provincias.map((d) => ({
provincia: d.provincia,
region: d.region,
re:
dataPorProvincia[d.provincia].find((d) => d.fecha == fechaMaximaRe) &&
+dataPorProvincia[d.provincia].find((d) => d.fecha == fechaMaximaRe)[
"r.estimado"
],
reSup:
dataPorProvincia[d.provincia].find((d) => d.fecha == fechaMaximaRe) &&
+dataPorProvincia[d.provincia].find((d) => d.fecha == fechaMaximaRe)[
"r.lisup"
],
reInf:
dataPorProvincia[d.provincia].find((d) => d.fecha == fechaMaximaRe) &&
+dataPorProvincia[d.provincia].find((d) => d.fecha == fechaMaximaRe)[
"r.liminf"
]
}))
Insert cell
Inputs.table(dataPorProvincia["Santiago"])
Insert cell
fechaMaximaRe
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Re estimado mayor a 1
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
Insert cell
Insert cell
Insert cell
Insert cell
## Vacunas al día
Insert cell
Insert cell
Insert cell
color = d3
.scaleOrdinal()
.domain(["segunda", "unica", "refuerzo", "cuarta"])
.range([
d3.schemeCategory10[3],
d3.schemeCategory10[6],
d3.schemeCategory10[1],
d3.schemeCategory10[0]
])
Insert cell
{
function sumaAlDia(d) {
return (
d.Segunda.nuevasEn6Meses +
d.Unica.nuevasEn6Meses +
d.Refuerzo.nuevasEn6Meses +
d.Cuarta.nuevasEn6Meses
);
}

function desgloseAlDia(d) {
return {
segunda: d.Segunda.nuevasEn6Meses,
unica: d.Unica.nuevasEn6Meses,
refuerzo: d.Refuerzo.nuevasEn6Meses,
cuarta: d.Cuarta.nuevasEn6Meses
};
}

const dataPlot = _.chain(dataEvoluciónVacunacion6Meses)
.map((d) => {
return _.map(desgloseAlDia(d.stats[targetLocation]), (value, key) => {
const record = {};
record.fecha = d.fecha;
record.tipo = key;
record.alDia = value;
return record;
});
})
.flatten()
.sortBy((d) => d.fecha)
.filter((d) => ["segunda", "unica", "refuerzo", "cuarta"].includes(d.tipo))
.value();

const maxDate = _.chain(dataPlot)
.map((d) => d.fecha)
.max()
.value();

const date6MonthsAgo = moment(maxDate)
.subtract(6, "months")
.format("YYYY-MM-DD");

const date12MonthsAgo = moment(maxDate)
.subtract(12, "months")
.format("YYYY-MM-DD");

const maxValue = _.chain(dataPlot)
.map((d) => d.alDia)
.max()
.value();

//return date6MonthsAgo;

return Plot.plot({
y: {
grid: true,
label: "Vacunas al día"
},
color: {
legend: true,
domain: color.domain(),
range: color.range()
},
marginRight: 100,
marginLeft: 100,
marks: [
Plot.areaY(
dataPlot.filter(
(d) =>
d.tipo == "refuerzo" ||
d.tipo == "cuarta" ||
d.tipo == "segunda" ||
d.tipo == "unica"
),
{
x: (d) => new Date(d.fecha),
y: "alDia",
fill: "tipo"
}
),
Plot.ruleX([
new Date(maxDate),
new Date(date12MonthsAgo),
new Date(date6MonthsAgo)
])
/*Plot.text(dataPlot, {
x: (d) => new Date(d.fecha),
dx: 10,
y: "alDia",
text: (d) =>
`${d3.format(".3s")(d["alDia"])} (${d3.format(".1%")(
d["alDia"] / maxValue
)}))`,
textAnchor: "start"
}),
Plot.ruleY([maxValue]),
Plot.text(
[{ fecha: maxDate, alDia: maxValue }],
Plot.selectLast({
x: (d) => new Date(d.fecha),
dx: 10,
y: "alDia",
text: (d) => `${d3.format(".3s")(d["alDia"])} `,
textAnchor: "start"
})
)*/
]
});
}
Insert cell
Insert cell
style_bootstrap
Insert cell
## Datos generales
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { ordenRegiones } from "@elaval/data-covid-19-chile"
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
setLocaleMoment_ES()
Insert cell
setLocaleD3_ES()
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