authorsByDate = {
const dateArray = [];
let cumulativeData = new Map();
dateRange.forEach(date => {
dateArray.push(cumulativeData);
cumulativeData = new Map(cumulativeData);
const currentData = dateGroupedData.get(date) || [];
currentData.forEach(datum => {
const key = datum.author;
if (!cumulativeData.has(key)) {
cumulativeData.set(key, 0);
}
cumulativeData.set(key, cumulativeData.get(key) + 1);
});
});
return dateArray.map(d =>
Array.from(d).map(t => ({ id: t[0], type: 'author', count: t[1] }))
);
}