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

add interactive version #17

Open
timelyportfolio opened this issue Jul 18, 2015 · 11 comments
Open

add interactive version #17

timelyportfolio opened this issue Jul 18, 2015 · 11 comments

Comments

@timelyportfolio
Copy link
Collaborator

I started working on an interactive version with the idea that it works seamlessly with the return treemap list. It is minimal and sparse now, but I would love your input. Happy to eventually roll it into treemap if you would like. All the code is https://github.com/timelyportfolio/d3treeR.

Thanks for such a great package.

@edwindj
Copy link
Collaborator

edwindj commented Jul 19, 2015

Great! +1 to roll it into treemap.

@mtennekes
Copy link
Owner

Brilliant! You're very welcome to add it to the treemap package, even though it is minimal working prototype. Some obvious thinks that can be improved:

  • The layout of the rectangles is different. Not a big deal, but it might be inconvenient when users switch between static and interactive.
  • The legend is not shown yet.

Again, thanks for bringing our R packages to life! If you need more ideas for the upcoming weeks: tabplot does have a prototype d3 version tabplotd3 https://github.com/edwindj/tabplotd3, but could be improved (or rewritten if you like) and transformed into a htmlwidget.

PS: the d3treeR code didn't work on my PC. I don't get any errors nor warnings, but the viewer pane in RStudio stays empty. These are my session_info() results:

setting  value                       
version  R version 3.2.1 (2015-06-18)
system   x86_64, mingw32             
ui       RStudio (0.99.467)          
language (EN)                        
collate  English_United States.1252  
tz       Europe/Berlin               

package      * version     date       source                                  
chron          2.3-47      2015-06-24 CRAN (R 3.2.1)                          
colorspace     1.2-6       2015-03-11 CRAN (R 3.1.3)                          
curl           0.9.1       2015-07-04 CRAN (R 3.2.1)                          
d3treeR      * 0.1         2015-07-19 Github (timelyportfolio/d3treeR@c7f45d1)
data.table     1.9.4       2014-10-02 CRAN (R 3.2.1)                          
data.tree      0.1.7       2015-07-19 Github (gluc/data.tree@e1997c8)         
devtools     * 1.8.0       2015-05-09 CRAN (R 3.2.1)                          
digest         0.6.8       2014-12-31 CRAN (R 3.1.2)                          
ggplot2        1.0.1       2015-03-17 CRAN (R 3.1.3)                          
git2r          0.10.1      2015-05-07 CRAN (R 3.2.0)                          
gridBase       0.4-7       2014-02-24 CRAN (R 3.0.3)                          
gtable         0.1.2       2012-12-05 CRAN (R 3.0.1)                          
htmltools      0.2.6       2014-09-08 CRAN (R 3.1.1)                          
htmlwidgets    0.5.1       2015-07-19 Github (ramnathv/htmlwidgets@d30d657)   
httpuv         1.3.2       2014-10-23 CRAN (R 3.1.2)                          
httr           1.0.0       2015-06-25 CRAN (R 3.2.1)                          
igraph         1.0.1       2015-06-26 CRAN (R 3.2.1)                          
jsonlite       0.9.16.9000 2015-07-19 Github (jeroenooms/jsonlite@4e4d10a)    
knitr          1.10.5      2015-05-06 CRAN (R 3.2.0)                          
magrittr       1.5         2014-11-22 CRAN (R 3.1.2)                          
MASS           7.3-40      2015-03-21 CRAN (R 3.2.1)                          
memoise        0.2.1       2014-04-22 CRAN (R 3.0.3)                          
mime           0.3         2015-03-29 CRAN (R 3.2.0)                          
munsell        0.4.2       2013-07-11 CRAN (R 3.0.1)                          
plyr           1.8.3       2015-06-12 CRAN (R 3.2.1)                          
proto          0.3-10      2012-12-22 CRAN (R 3.0.0)                          
R6             2.1.0       2015-07-04 CRAN (R 3.2.1)                          
RColorBrewer   1.1-2       2014-12-07 CRAN (R 3.1.2)                          
Rcpp           0.11.6      2015-05-01 CRAN (R 3.2.0)                          
reshape2       1.4.1       2014-12-06 CRAN (R 3.1.2)                          
rstudioapi     0.3.1       2015-04-07 CRAN (R 3.2.0)                          
rversions      1.0.2       2015-07-13 CRAN (R 3.2.1)                          
scales         0.2.5       2015-06-12 CRAN (R 3.2.1)                          
shiny          0.12.1      2015-06-12 CRAN (R 3.2.1)                          
stringi        0.5-5       2015-06-29 CRAN (R 3.2.1)                          
stringr        1.0.0       2015-04-30 CRAN (R 3.2.0)                          
treemap      * 2.3         2015-06-26 CRAN (R 3.2.1)                          
xml2           0.1.1       2015-06-02 CRAN (R 3.2.1)                          
xtable         1.7-4       2014-09-12 CRAN (R 3.1.1)                          
yaml           2.1.13      2014-06-12 CRAN (R 3.1.1) 

@timelyportfolio
Copy link
Collaborator Author

Very odd that it did not work for you. I know data.tree is rapidly iterating and caused an issue for another user, but it appears you have the newest version of that. Also, an outdated version of data.tree would have caused errors or warnings in the R console.

What happens when you click the button in RStudio to show in the browser? Does it also show an empty screen? If possible, could you do htmlwidgets:::saveWidget() and copy/paste it into a gist?

I have struggled with how to handle the layout of the rectangles. It illustrates the plus/minus of the different techniques for interactivity as we have discussed in tmap. While treemap nicely provides a x, y, width, and height that we can replicate in the interactive version, much of the interactivity such as zoom, etc. depends on the d3.js layout which produces different x and y with its own algorithm. I would love to eventually get to full parity in the layouts and will continue to explore. In the treemap case, I think this approach works better since the zoom, etc. is so critical
to the experience.

Legends are critical.

I think instead of making a new htmlwidget this week, I'll bend the self-imposed rules a bit and continue iterating on d3treeR.

@mtennekes
Copy link
Owner

The SVG is empty:

capture

@timelyportfolio
Copy link
Collaborator Author

Do you see any errors in the JavaScript debugger? Ctrl + Shift + I or F12 in Chrome

@mtennekes
Copy link
Owner

20:18:20.513 TypeError: d.parent is undefined1 d3tree.js:184:16

@timelyportfolio
Copy link
Collaborator Author

Darn, not sure what is happening? Looks like we match on all our package versions. Are you using the following example?

library(d3treeR)
library(treemap)

data(GNI2010)
d3tree(
    treemap(
        GNI2010,
        index=c("continent", "iso3"),
        vSize="population",
        vColor="GNI",
        type="value"
    )
    ,rootname = "World"
)

Does the non-treemap version work?

library(d3tree)
d3tree(
  "http://bl.ocks.org/mbostock/raw/4063269/flare.json"
  ,id = "name"
)

Would you mind devtools::install_github("timelyportfolio/d3treeR") one more time? I doubt seriously that it changes things, but worth a shot.

@mtennekes
Copy link
Owner

Still no succes, but the non-treemap version works!
Maybe this will help:

data <- d3treeR:::convert_treemap(treemap(
    GNI2010,
    index=c("continent", "iso3"),
    vSize="population",
    vColor="GNI",
    type="value")$tm, rootname="World")
str(data, max.level=2)
    List of 9
     $ name         : chr "World"
     $ id           : int 1
     $ size         : num NA
     $ Africa       :List of 64
      ..$ name       : chr "Africa"
      ..$ color      : chr "#006837"
      ..$ h          : num 0.572
      ..$ id         : int 2
      ..$ size       : num 954502
      ..$ vColor     : num 106410
      ..$ vColorValue: num 106410

@timelyportfolio
Copy link
Collaborator Author

Ok, I think I see now. Looks like data.tree has changed again. I think I can sort it out soon.

@timelyportfolio
Copy link
Collaborator Author

@mtennekes will you reinstall, and see if it is working again? Sorry for this. Thanks so much for working through it with me.

@mtennekes
Copy link
Owner

Yes, it's working! Nice job!

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

3 participants