Using the d3.js library, I wanted to create a lookup like so:
var lookup = d3.nest()
.key((d: any) => d.day)
.rollup((leaves: any) => {
return d3.sum(leaves, (d: any) => { return parseInt(d.count); }) as any;
})
.object(dateData);
So I can use it later:
rect.filter(function (d) { return d in lookup; })
.style("fill", function (d) { return d3.interpolatePuBu(scale(lookup[d])); })
.select("title")
.text((d) => this.titleFormat(new Date(d)) + ": " + lookup[d]);
Unfortunately this has been throwing a:
"export 'nest' (imported as 'd3') was not found in 'd3'
After much search I found out that in v4 of d3, which I am using nest was replaced with group. Now I can't find anything in the documentation and I was trying to achieve similar with:
var lookup = d3.group(data, (d: any) => d.day)
.rollup((leaves: any) => {
return d3.sum(leaves, (d: any) => { return parseInt(d.count); }) as any;
})
.object(dateData);
But this doesn't seem to even compile. How would I go around achieving what I am trying to do?