dailylog 3-28-20

less than 1 minute read

DO NOT FORGET:

Getting dates to work in d3

EXPLAINED IN FULL HERE

Similarly, here’s the set of dates. But our approach here is different. We’ll construct a nested map from date and name to value. Then we’ll convert this to an array to order the data chronologically.

datevalues = Array.from(d3.rollup(data, ([d]) => d.value, d => +d.date, d => d.name))
  .map(([date, data]) => [new Date(date), data])
  .sort(([a], [b]) => d3.ascending(a, b))