Built with blockbuilder.org
d3-flextree
lays out hierarchical trees similar to Reingold/Tilford but with flexible sizes. I thought a good test would be to look at a treemap as a flextree.
This is very experimental.
#requires experimental branch of networkD3
# devtools::install_github("timelyportfolio/networkD3@experiment/flextree")
library(treemap)
library(d3treeR)
library(networkD3)
# example 1 from ?treemap
data(GNI2010)
tm <- treemap(
GNI2010
,index=c("continent"),#, "iso3")
,vSize="population"
,vColor="GNI"
,type="value"
)
tm$tm$y_size <- tm$tm$w * 100
tm$tm$x_size <- tm$tm$h * 100
tm_d3 <- d3treeR:::convert_treemap(tm$tm,rootname="world")
tm_d3$x_size <- 100
tm_d3$y_size <- 100
flexNetwork(tm_d3,spacing = htmlwidgets::JS("function(a,b){return 1}"))