data = {
const json = await FileAttachment("history-test.min.json").json();
const jsonData = json.data;
const dates = jsonData.dates.slice(0, numDays);
const continents = d3Array.groups( jsonData.places, d => d.continent );
console.clear();
console.log('................ data block..........');
const d = dates.map(
(date, idx) => {
console.log('............date block');
const continentData = continents.map(
(continent) => {
const total = continent[1].reduce( (acc,cur) => {
return acc + cur.deaths[idx];
}, 0)
console.log('total', total);
return [ continent[0], total ];
}
)
console.log(continentData);
let asObject = {};
continentData.forEach( (d) => {
console.log(d);
asObject[d[0]] = d[1]
}
);
return Object.assign( { "date" : new Date(date) }, asObject );
}
)
console.log(d);
const cols = Object.keys(d[0]).filter( d => d !== 'date' );
return Object.assign( d, { columns: cols, y: "number of deaths"} )
}