AdeelK93 / collapsibleTree

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

Node spacing issue with large nodes #34

Open jl5000 opened 6 years ago

jl5000 commented 6 years ago

Hi,

We're using your fantastic package to visualise some data, and using both node colour and size to represent frequency and a 'value' attribute. Unfortunately this has created an issue with node spacing as small nodes are appearing 'within' large nodes, presumably because the spacing is being measured from the node centres.

It would be really good if the package could account for node size variability by incorporating radius into the spacing calculations as well.

AdeelK93 commented 6 years ago

hmmm I can try to take a stab at this, but I can see this turning out to be one of those "hard problems" of visualization. do you example data/code exemplifying this problem? thanks!

jl5000 commented 6 years ago
library(collapsibleTree)

test <- data.frame(cat1=c('a','b','c','d','e','f'),
                   cat2=c('h','i','j','k','l','m'),
                   num1=c(40,2,3500,700,150,12))

collapsibleTreeSummary(test, hierarchy = c('cat1','cat2'),nodeSize = 'num1')
AdeelK93 commented 6 years ago

rplot

I've tweaked some node separation logic in the github version, how does this look?

jl5000 commented 6 years ago

Thanks so much for looking into this, it looks great. I'm on holiday at the moment, but I'll pass it on when I'm back and let you know how it goes :)

rferrisx commented 6 years ago

I am loathe to add any "hard" problems of visualization to your code because clearly this is a brilliant CRAN project. (Thank You!!) The question of "many nodes" will always be difficult. You can see in the diagrams below that split WA legislative districts into precincts what happens with many nodes. Nonetheless, there may be added functionality you could think about:

(1) splitting large trees into partial display and a link to display second third, bottom third etc. (2) making the link button/circle configurable in size separate from the text Font. Obviously, it automatically changes together now. (3) Of course, the obvious answer is to create smaller subsets in our data, but this adds more work for your users.

Thanks so much again. Really a great project. I really appreciate fitting D3.js functionality into an R library with such simplicity and clarity.

Ryan M. Ferris

collapsedtree_capture

collapsedtree_capture_001