data = {
const timeParser = d3.timeParse("%d %b %Y");
const csvString = await FileAttachment("Cells in Journal_ Getting Started with Data Viz - Journal cells - 12 Jun 2020.csv").text();
const rowConversionFunction = ({
"Title": title,
"URL": url,
"Number of cells": y,
"Date": x
}) => ({
title,
url,
x: timeParser(x),
dayOfWeek: timeParser(x),
y: +y
});
let dataObjectTarget = d3.csvParse(csvString, rowConversionFunction);
dataObjectTarget = d3.rollups(dataObjectTarget, v => d3.format("d")(d3.mean(v, d => d.y)), d => d3.timeFormat("%a")(d.dayOfWeek))
.map(d => ({x: d[0], y: d[1] }));
const extraPropertiesSource = {xAxisLabel: "Day of the week", yAxisLabel: "Cells (mean)", caption: "This bar chart shows average cells written each day of the week, where Saturday is highlight with the highest mean cells written of 42."};
return Object.assign(dataObjectTarget, extraPropertiesSource);
}