data = {
const input = await d3.csv(url, ({ amount, timestamp }) => {
return {
amount: Number.parseInt(amount, 10),
timestamp: new Date(timestamp * 1000)
};
});
const data = input.map(({ amount, timestamp }, idx, arr) => {
let difference = null;
if (idx + 1 !== arr.length) {
const prev = arr[idx + 1].amount;
difference = amount - prev;
}
return { difference, timestamp };
});
return data;
}