May 2019
Beginner to intermediate
650 pages
14h 50m
English
Finally, you can transform each leaf object and replace it with derived or filtered data using the rollup() method with a reduction function based on the values array. For example, this code will replace each leaf object with a string in a value key (see Collections/7-nesting-rollup.html):
const groupByDirector = d3.nest() .key(d => d.director) .sortKeys((a,b) => d3.ascending(a, b)) .sortValues((a,b) => d3.ascending(a.year, b.year)) .rollup(values => values.map(d => `${d.title} (${d.year})`)) .entries(movies);
The result of running the preceding code is as follows:
[ { key: "Guillermo del Toro", value: ["El Laberinto del Fauno (2006)", "The Shape of Water (2017)"] },{ key: "Patty Jenkins", value: ["Wonder Woman (2017)"] },{ key: "Stanley ...Read now
Unlock full access