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] Allow map to be partially un-collapsed by default #64

Open rlderi opened 2 years ago

rlderi commented 2 years ago

There are many cases where it would be very useful to have the collapsibleTree expanded to a particular node by default, rather than either completely collapsed or completely expanded. For an example implementation, the expandTo column below would tell the map to render with the path from root to Ida expanded, and the rest of the map collapsed.

org <- data.frame(
  Manager = c(
    NA, "Ana", "Ana", "Bill", "Bill", "Bill", "Claudette", "Claudette", "Danny",
    "Fred", "Fred", "Grace", "Larry", "Larry", "Nicholas", "Nicholas"
  ),
  Employee = c(
    "Ana", "Bill", "Larry", "Claudette", "Danny", "Erika", "Fred", "Grace",
    "Henri", "Ida", "Joaquin", "Kate", "Mindy", "Nicholas", "Odette", "Peter"
  ),
  Title = c(
    "President", "VP Operations", "VP Finance", "Director", "Director", "Scientist",
    "Manager", "Manager", "Jr Scientist", "Operator", "Operator", "Associate",
     "Analyst", "Director", "Accountant", "Accountant"
  ),
  expandTo = c(rep(FALSE, 9), TRUE, rep(FALSE, 6))
)