Public
Edited
May 22, 2023
Insert cell
Insert cell
Insert cell
// viewof selectedDiseases = searchCheckbox(diseases, {label: "Select Diseases to show", value: diseases, height: 150})
Insert cell
Insert cell
Insert cell
viewof selected = TimeSearcher({
data: filteredParsedMetadata,
id: d => d.disease,
x: d => d.date,
y: d => d.count,
width: width*.8,
height: 300,
hasDetails: false,
detailsHeight: 100,
yScale: () => d3.scalePow().exponent(0.5)
})
Insert cell
diseasesSelectedByTimelines
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
selected
Insert cell
makeHist = (data, attr) => {
const bar = vl.markBar().encode(vl.y().fieldN(attr), vl.x().count());
const all = bar.data(referenceMetadata).encode(vl.color().value("#eee"));
const selected = bar.data(data);
return vl.layer(selected).title(attr).render();
}
Insert cell
Insert cell
Insert cell
referenceMetadata = diseases.map(d => mapMetadata.get(d))
Insert cell
metadata = {
const geos = d3.tsvParseRows(
await FileAttachment("results_out.json_geo_regions.txt").text()
);
const diseases = d3.tsvParseRows(
await FileAttachment("results_out.json_disease.txt").text()
);
const dates = d3.tsvParseRows(
await FileAttachment("results_out.json_dates.txt").text()
);

return diseases.map((d, i) => ({
id: d[0],
disease: d[1],
geo: geos[i][1],
date: dates[i][1]
}));
}
Insert cell
parsedMetaData2 = metadata
.map((d) => ({ ...d, pdate: new Date(d.date) }))
.filter(
(d) =>
d.pdate instanceof Date &&
!isNaN(d.pdate) &&
d.pdate >= new Date(1980, 0, 0) &&
d.pdate <= new Date(2024, 0, 0)
)
Insert cell
d3.rollups(
parsedMetaData2,
(v) => d3.count(v, (d) => d.pdate),
(d) => d.disease,
// (d) => d.geo,
(d) => d.pdate,
)
Insert cell
navio(parsedMetaData2)
Insert cell
Insert cell
vl.markLine({tooltip: true})
.encode(vl.x().fieldT("date").timeUnit("yearweek"), vl.y().count(), vl.detail().fieldN("disease"))
.width(width*.8)
.data(navioSelected)
.render()
Insert cell
clusters = d3.tsvParseRows(await FileAttachment("clusters_1000@1.txt").text())
Insert cell
vl.markBar().encode(vl.y().fieldQ("0"), vl.x().count()).data(clusters).render()
Insert cell
vl
.markBar()
.encode(vl.y().fieldQ("id"), vl.x().count())
.data(
metadata.map((d) => {
d.id = +d.id;
return d;
})
)
.render()
Insert cell
// metadata.map((d) => {
// d.id = +d.id;
// return d;
// })
Insert cell
mapMetadata = new Map(metadata.map(d => [d.disease, d] ))
Insert cell
// data = FileAttachment("timelines.csv")
// .csv({ typed: true })
// .then((res) =>
// res.map((d) => {
// d.disease = d.name.split("_").slice(1).join(" ");
// const metadata = mapMetadata.get(d.disease)
// return Object.assign(d, metadata);
// })
// )
Insert cell
import {navio} from "@john-guerra/navio"
Insert cell
import {TimeSearcher} from "@ivelascog/timesearcher-plus-usabilidad"
Insert cell
import {multiAutoSelect} from "@john-guerra/multi-auto-select"
Insert cell
import {searchCheckbox} from "@john-guerra/search-checkbox"
Insert cell
import {TimeParser, flatTree} from "@john-guerra/time-parser"
Insert cell
import {FacetedSearch} from "@john-guerra/faceted-search"
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