AdeelK93 / collapsibleTree

Create Interactive Collapsible Tree Diagrams in R using D3.js
https://adeelk93.github.io/collapsibleTree/
158 stars 41 forks source link

leaves with different depth #5

Closed fengqifang closed 7 years ago

fengqifang commented 7 years ago

Great package.

Just one question, if I'd like to present a 'paths' structure using this package, which leaves may not have the same depth.

For example, Root(100) have 3 children, A(50), B(20), C(30), then there is no child for node A, node B and C may continue to grow, in such case, how to arrange the data.tree structure?

AdeelK93 commented 7 years ago

The github version of the package supports this feature more or less by making the children NAs, does that work for you?

fengqifang commented 7 years ago

Oh, will try it, did not see an example in the examples document.

fengqifang commented 7 years ago

tested it, it works well, thank you.

I have another two question

1) is that possible give label for each level of tree, not only the root, i.e., show the hierarchy levels at the top of each level of the tree?

2) The arguments 'attribute' in collapsibleTree() does not show up, though it works well in collapsibleTreeSummary. Is that possible I can use the 'attribute' showing some other information corresponding the node, not necessary in the input data.

Thank you

AdeelK93 commented 7 years ago

You're right, that definitely should be included in the examples document. Fixed!

  1. I'm not completely sure what you mean by that. Every level of the tree has labels. Unless you mean something like:
warpbreaks %>%
  mutate(
    wool = paste("wool:", wool),
    tension = paste("tension:", tension)
  ) %>%
  collapsibleTree(c("wool", "tension"))
  1. So the attribute argument in collapsibleTree and collapsibleTreeSummary are both tied to tooltips, but in collapsibleTreeSummary, it is additionally mapped to color gradient. But you need to enable the tooltip for it to show up. This attribute does not need to be a part of the input data. I have updated the examples to make this more clear:
collapsibleTree(
  warpbreaks, c("wool", "tension", "breaks"),
  tooltip = TRUE,
  attribute = "breaks"
)