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

renderD3tree not giving correct opening view for multilevel d3tree2 objects #13

Closed
ellisp opened this issue Jul 26, 2015 · 4 comments
Closed

Comments

@ellisp
Copy link

ellisp commented Jul 26, 2015

You might know all about this already. When you print the object tmd3, as created in the code at the bottom of this comment, straight from the R console it correctly renders in the browser like this:

image

When it's rendered in a Shiny app, it looks like this:
image
It's trying to show all the levels at once, not just the top level of the hierarchy.

library(shiny)
library(treemap)
library(d3treeR)
library(htmlwidgets) # see https://github.com/timelyportfolio/d3treeR/issues/11

Var1 <- letters[1:5]
Var2 <- LETTERS[1:5]
Var3 <- c("Tiger", "Lion", "Bear", "Penguin", "Eagle", "Aardvark")

ThreeLevels <- expand.grid(Var1, Var2, Var3)
n <- nrow(ThreeLevels)
ThreeLevels$Size <- abs(rnorm(n, 12, 3))
ThreeLevels$Colour <- rnorm(n, 0, 1)

tm <- treemap(ThreeLevels, index = c("Var1", "Var2", "Var3"), 
            vSize = "Size", vColor = "Colour",
            type = "value", palette = "Spectral",
            fun.aggregate="weighted.mean")

tmd3 <- d3tree2(tm)            


shinyApp(
  ui = fluidPage(
    sidebarLayout(
      sidebarPanel(p("Hello world")),
      mainPanel(d3treeOutput("tree"))
    )
  ), 
  server = function(input, output) {
    output$tree <- renderD3tree(tmd3)
   }
)
@timelyportfolio
Copy link
Collaborator

Well, if I continue to have d3tree and d3tree2 then I will need to also add separate Shiny render functions for d3tree2. I'm not crazy about having two versions of d3tree, but I have not yet thought of a better way.

@timelyportfolio
Copy link
Collaborator

See c0e312c for a temporary solution.

@timelyportfolio
Copy link
Collaborator

@ellisp, going to close for now. Let me know if you would like to reopen.

@ellisp
Copy link
Author

ellisp commented Aug 22, 2015

works fine for now, thanks

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