Skip to content

node.sum/count for non-numeric data  #176

@DDDgfx

Description

@DDDgfx

when using d3.group, or the previous d3.nest, and passing to d3.hierarchy, the composition of node.data differs between parent and leaf nodes.

Node.data for leaf nodes contains the key-value pairs from the original flat data, while parent nodes contain an array with a string of the group's name as the first element followed by an array of the children's leaf data.

Creating mouse-interaction, doing key-based joins for animated updates hierarchical layouts and force diagrams is difficult because parent nodes don't contain an id other than the function created d.index, or any of the fields from the nodes.

Could a function like .sum or .count help? Instead of populating .value with a number, it might populate another property and contain a "name" or id (I might concatenate the names of all parent nodes + the group name), and additional key values for any leaf properties that have shared values among all the leaves.

Or could .data be reformed to have a similar structure in both leaf and parent nodes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions