The goal of d3hierR
is to provide some foundational htmlwidgets
for hierachies using d3. I do not know how far I will go with this package.
You can install d3hierR
from github with:
# install.packages("devtools")
devtools::install_github("timelyportfolio/d3hierR")
Currently, only a treemap is provided in d3hierR
with the function tree
.
Here is a quick look at d3hierR::tree()
with some random hierarchical data.
library(treemap)
library(d3r)
library(d3hierR)
rhd <- treemap::random.hierarchical.data()
rhd_nest <- d3r::d3_nest(rhd, value_cols = "x")
#> Warning: package 'bindrcpp' was built under R version 3.4.1
tree(rhd_nest, sizeField = "x")
library(treemap)
library(d3r)
library(d3hierR)
rhd <- treemap::random.hierarchical.data()
rhd_nest <- d3r::d3_nest(rhd, value_cols = "x")
tree(
rhd_nest,
sizeField = "x",
paddingOuter = 20,
tile = htmlwidgets::JS("d3.treemapBinary")
)
The clipText
argument will use a very simple test to clip any label text that is too wide or high to fit in its rectangle. Also, we can use the styleText
argument to decrease the font size.
library(treemap)
library(d3r)
library(d3hierR)
rhd <- treemap::random.hierarchical.data()
rhd_nest <- d3r::d3_nest(rhd, value_cols = "x")
tree(
rhd_nest,
sizeField = "x",
paddingOuter = 20,
tile = htmlwidgets::JS("d3.treemapBinary"),
styleText = list("font-size" = "70%"),
clipText = TRUE
)
I built a lot more into it, but out of time for more examples ...
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.