Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

d3r nesting order for SearchTree widget #8

Closed
yonicd opened this issue Dec 4, 2016 · 2 comments
Closed

d3r nesting order for SearchTree widget #8

yonicd opened this issue Dec 4, 2016 · 2 comments

Comments

@yonicd
Copy link

yonicd commented Dec 4, 2016

#Doesnt give the value column in the leaves when branch fully grown
Titanic%>%as.data.frame

#Does give the value column in the leaves when branch fully grown
Titanic%>%data.frame%>%mutate(value=NA)%>%distinct

#Current Call
  #d3_nest doesnt nest in the correct order for ggtree.js making the links float to the last open parent
ggtree(
  list(
    root = d3r::d3_nest(
      Titanic%>%data.frame%>%mutate(value=NA)%>%distinct,
      value_cols = "Freq"
    ),
    layout = "collapse"
  ),
  name = "id",
  value = "colname"
)

#Call with old df2tree function
  #df2tree nests in the correct order for ggtree.js giving a unique parent for each child
ggtree(
  list(
    root=df2tree(Titanic%>%data.frame%>%mutate(value=NA)%>%distinct),
    layout = "collapse"
  ),
  name = "name",
  value = "value"
)
#Compare different nesting orders visually
jsonedit(d3r::d3_nest(
  Titanic%>%data.frame%>%mutate(value=NA)%>%distinct,
  value_cols = "Freq",
  json = F
))

d3nest

jsonedit(df2tree(Titanic%>%data.frame%>%mutate(value=NA)%>%distinct))

df2treenest

@timelyportfolio
Copy link
Owner

timelyportfolio commented Dec 5, 2016

ok, this is because the node id are not unique, which I believe is more of an issue with the JavaScript, but I'll keep digging.

In my opinion, expecting correct order is an unexpected burden especially on an unsuspecting R user who might not understand scope and reference in JavaScript. Requiring an id (unique) separate from name is probably more robust.

@timelyportfolio
Copy link
Owner

moving discussion to timelyportfolio/SearchTree#2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants