Published
Edited
Sep 13, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = {
const rowConversionFunction = ({
"Name": name,
"Visits": visits
}) => {
return {
name,
visits: +visits
}};
const data5Jul = await d3.tsvParse(tsv5Jul, rowConversionFunction);
const data25Jul = await d3.tsvParse(tsv25Jul, rowConversionFunction);
// NOTE: there's probably a more succinct way to default previously non-existent cats to 0 visits
let dataObjectTarget = [];
data25Jul.forEach(after => {
if (data5Jul.some(before => before.name === after.name)) {
dataObjectTarget.push({
name: after.name,
visits: [data5Jul.find(before => before.name === after.name).visits, after.visits]
})
}
else {
// dataObjectTarget.push({
// name: after.name,
// visits: [0, after.visits]
// })
}
});

const extraPropertiesSource = {
columns: ["5 July 2020", "25 July 2020"],
xAxisLabel: "Goodies",
yAxisLabel: "Cats",
observation: "",
title: "Changes in cat visits.",
};
return Object.assign(dataObjectTarget, extraPropertiesSource);
}
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