Skip to content
This repository has been archived by the owner on Nov 11, 2018. It is now read-only.

Add custom factory support for nest #27

Closed
wants to merge 1 commit into from
Closed

Conversation

nyurik
Copy link

@nyurik nyurik commented Apr 21, 2018

A more generic approach to customize new node creation using a factory method.

This allows (for example) to create sub-aggregations for each node of all sub-nodes without doing a complex postprocessing (no need to implement tree iteration)

d3.nest().factory((k, v) => (
  {
    key: k,
    values: v,
    sum: v.reduce((acc, vv) => acc + vv.sum, 0)
  }
).key( v => v.foo ).entries([
  {foo: 'a', sum: 10},
  {foo: 'b', sum: 15},
  ...
]).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants