Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable tree data as an object using the hierarchy of its properties #98

Merged
merged 14 commits into from
Sep 18, 2022

Conversation

stockiNail
Copy link
Collaborator

@stockiNail stockiNail commented Sep 7, 2022

Fix #81

This PR is implementing the feature to set the tree of the data as an object. This enables to use native hierarchy.
The normalization is done using the keys of the object as possible groups, in order to apply the group by on the data.

{
  A: {
    C: {
      value: 1
    }
  },
  B: {
    D: {
      value: 1
    }
  }
}

is transformed to an array, manageable by the treemap controller,

[
  {0: 'A', _leaf: 'C', value: 1},
  {0: 'B', _leaf: 'D', value: 1},
]

where 0 and _leaf are keys you can use in the groups options, to group by,

datasets: [{
  key: 'value',
  groups: [0, '_leaf'],
  ...
}]

It also adds an additional options, treeLeafKey, where you can set the name of the property where storing the leaf node name. By default is _leaf.

@stockiNail stockiNail added the enhancement New feature or request label Sep 16, 2022
@stockiNail stockiNail added this to the 2.1.0 milestone Sep 16, 2022
@stockiNail stockiNail marked this pull request as ready for review September 16, 2022 09:18
@stockiNail stockiNail requested a review from kurkle September 16, 2022 09:18
Copy link
Owner

@kurkle kurkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, could you add some samples too?

@stockiNail
Copy link
Collaborator Author

Looks good, could you add some samples too?

Added

@kurkle kurkle merged commit b91f42a into kurkle:next Sep 18, 2022
@stockiNail stockiNail deleted the objectTree branch September 26, 2022 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to display nested / hierarchical data?
2 participants