AdeelK93 / collapsibleTree

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

[Feature Request] Could we use a different variable for attribute? #13

Open hestiri opened 7 years ago

hestiri commented 7 years ago

This is such a great package! Is this possible to define another method in attribute instead of "leafCount" in collapsibleTreeSummary? I need a mean function that for each node sums up the numeric values defined in attribute and divides them by the number of leaves.

AdeelK93 commented 7 years ago

So right now you can change the attribute to another column name, and get the sum of that other column like this:

collapsibleTreeSummary(
  warpbreaks,
  c("wool", "tension", "breaks"),
  attribute = "breaks",
  fillFun = colorspace::terrain_hcl,
  maxPercent = 50
)

However, I haven't yet worked on adding additional aggregation functions other than just cumulative sum for the summary function, since I was having some trouble getting the node filling to work right. The regular collapsibleTree function does support using any aggregation function, but it will not automatically add a color gradient to your nodes.

kegarner commented 5 years ago

Is there a work around to using collapsibleTree and getting the color gradient. I'm using mean for my aggFun so I can't use collapsibleTreeSummary.