AdeelK93 / collapsibleTree

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

Is there a way to resize the size of the nodes based on the attribute supplied? #14

Closed adhok closed 7 years ago

adhok commented 7 years ago

I am really grateful for the package as I am using it to represent a path data set. I was wondering if there is a way/workaround to change the size of the nodes based on the attribute. I have included a simple reproducible example as follows.

V1 <- structure(c(5L, 5L, 5L, 5L, 5L, 5L), .Label = c("Display", "Email", 
"SEM", "SEO", "Social"), class = "factor")
V2 <- structure(c(6L, 6L, 6L, 6L, 6L, 6L), .Label = c("", "Display", 
"Email", "SEM", "SEO", "Social"), class = "factor")
V3 <- structure(c(4L, 4L, 4L, 4L, 4L, 3L), .Label = c("", "Email", 
"SEO", "Social"), class = "factor")
Paths <- c(30L, 40L, 71L, 156L, 273L, 40L)

data_paths <- data.frame(V1,V2,V3,Paths)
collapsibleTree(data_paths,hierarchy = c('V1','V2','V3'),attribute = "Paths",tooltip = T)
AdeelK93 commented 7 years ago

Thanks for the great suggestion! I've added an option for nodeSize in the github version of the package, which can be used like:

collapsibleTree(data_paths,hierarchy = c('V1','V2','V3'),attribute = "Paths",tooltip = T, nodeSize = "Paths")

How does that work for you?