diff --git a/README.md b/README.md
index c573137..7c27c24 100644
--- a/README.md
+++ b/README.md
@@ -87,10 +87,11 @@ shiny::runApp(system.file("examples/03shiny", package = "collapsibleTree"))
``` r
library(collapsibleTree)
date()
-#> [1] "Sun Mar 19 18:08:24 2017"
+#> [1] "Sun Mar 19 18:37:10 2017"
testthat::test_dir("tests/testthat")
#> Error handling: ..........
+#> Margin sizing: ................
#> Root labelling: ..........
#>
#> DONE ======================================================================
diff --git a/docs/index.Rmd b/docs/index.Rmd
index a2072c7..4bdff5f 100644
--- a/docs/index.Rmd
+++ b/docs/index.Rmd
@@ -14,7 +14,7 @@ load(system.file("extdata/Geography.rda", package = "collapsibleTree"))
## Overview
collapsibleTree is an R [htmlwidget](http://www.htmlwidgets.org/) that allows you to create interactive collapsible Reingold–Tilford tree diagrams using D3.js, adapted from Mike Bostock's [example](https://bl.ocks.org/mbostock/4339083). Turn your data frame into a hierarchical visualization without worrying about nested lists or JSON objects!
-
+
If you're using [Shiny](https://shiny.rstudio.com/), you can bind the most recently clicked node to a Shiny input, allowing for easier interaction with complex nested objects. The input will return a named list containing the most recently selected node, as well as all of its parents. See the [Shiny example](https://adeelk93.shinyapps.io/collapsibletree/) for more info.
## Installation
@@ -95,12 +95,12 @@ countryColors <- Geography %>%
Geography %>%
arrange(continent, type, country) %>%
-collapsibleTree(
- hierarchy = c("continent", "type", "country"),
- root = "Geography",
- width = 800,
- fill = c("white", continentColors, typeColors$colors, countryColors$colors)
-)
+ collapsibleTree(
+ hierarchy = c("continent", "type", "country"),
+ root = "Geography",
+ width = 800,
+ fill = c("white", continentColors, typeColors$colors, countryColors$colors)
+ )
```
## Basing Gradients on a Numeric Column
diff --git a/docs/index.html b/docs/index.html
index ca99043..140e1fb 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -176,8 +176,8 @@
Rendering the plot
hierarchy = c("continent", "type", "country"),
width = 800
)
-
-
+
+
Adding Colors
@@ -197,8 +197,8 @@
Adding Colors
rep("green", length(unique(Geography$country)))
)
)
-
-
+
+
Using Gradients
@@ -223,14 +223,14 @@
Using Gradients
Geography %>%
arrange(continent, type, country) %>%
-collapsibleTree(
- hierarchy = c("continent", "type", "country"),
- root = "Geography",
- width = 800,
- fill = c("white", continentColors, typeColors$colors, countryColors$colors)
-)
-
-
+ collapsibleTree(
+ hierarchy = c("continent", "type", "country"),
+ root = "Geography",
+ width = 800,
+ fill = c("white", continentColors, typeColors$colors, countryColors$colors)
+ )
+
+
Basing Gradients on a Numeric Column
@@ -246,8 +246,8 @@
Basing Gradients on a Numeric Column
width = 800,
attribute = "Number of Countries"
)
-
-
+
+
diff --git a/inst/examples/01rmd/Example01.Rmd b/inst/examples/01rmd/Example01.Rmd
index 9b8d70d..34d9d92 100644
--- a/inst/examples/01rmd/Example01.Rmd
+++ b/inst/examples/01rmd/Example01.Rmd
@@ -82,12 +82,12 @@ countryColors <- Geography %>%
Geography %>%
arrange(continent, type, country) %>%
-collapsibleTree(
- hierarchy = c("continent", "type", "country"),
- root = "Geography",
- width = 800,
- fill = c("white", continentColors, typeColors$colors, countryColors$colors)
-)
+ collapsibleTree(
+ hierarchy = c("continent", "type", "country"),
+ root = "Geography",
+ width = 800,
+ fill = c("white", continentColors, typeColors$colors, countryColors$colors)
+ )
```
## Basing Gradients on a Numeric Column
diff --git a/inst/examples/01rmd/Example01.html b/inst/examples/01rmd/Example01.html
index ecdd7e4..daf7c77 100644
--- a/inst/examples/01rmd/Example01.html
+++ b/inst/examples/01rmd/Example01.html
@@ -165,8 +165,8 @@ Rendering the plot
hierarchy = c("continent", "type", "country"),
width = 800
)
-
-
+
+
Adding Colors
@@ -186,8 +186,8 @@
Adding Colors
rep("green", length(unique(Geography$country)))
)
)
-
-
+
+
Using Gradients
@@ -212,14 +212,14 @@
Using Gradients
Geography %>%
arrange(continent, type, country) %>%
-collapsibleTree(
- hierarchy = c("continent", "type", "country"),
- root = "Geography",
- width = 800,
- fill = c("white", continentColors, typeColors$colors, countryColors$colors)
-)
-
-
+ collapsibleTree(
+ hierarchy = c("continent", "type", "country"),
+ root = "Geography",
+ width = 800,
+ fill = c("white", continentColors, typeColors$colors, countryColors$colors)
+ )
+
+
Basing Gradients on a Numeric Column
@@ -235,8 +235,8 @@
Basing Gradients on a Numeric Column
width = 800,
attribute = "Number of Countries"
)
-
-
+
+
diff --git a/tests/testthat/test-margin.R b/tests/testthat/test-margin.R
new file mode 100644
index 0000000..b97c62c
--- /dev/null
+++ b/tests/testthat/test-margin.R
@@ -0,0 +1,51 @@
+library(collapsibleTree)
+library(tibble)
+load(system.file("extdata/Geography.rda", package = "collapsibleTree"))
+context("Margin sizing")
+
+geo <- collapsibleTree(
+ Geography,
+ hierarchy = c("continent", "type", "country")
+)
+geoSummary <- collapsibleTreeSummary(
+ Geography,
+ hierarchy = c("continent", "type", "country")
+)
+
+test_that("left margins are the correct size - data frame", {
+ expect_gt(geo$x$options$margin$left, 50)
+ expect_gt(geoSummary$x$options$margin$left, 50)
+ expect_lt(geo$x$options$margin$left, 100)
+ expect_lt(geoSummary$x$options$margin$left, 100)
+})
+
+test_that("right margins are the correct size - data frame", {
+ expect_gt(geo$x$options$margin$right, 250)
+ expect_gt(geoSummary$x$options$margin$right, 250)
+ expect_lt(geo$x$options$margin$right, 300)
+ expect_lt(geoSummary$x$options$margin$right, 300)
+})
+
+Geography <- as_tibble(Geography)
+geo <- collapsibleTree(
+ Geography,
+ hierarchy = c("continent", "type", "country")
+)
+geoSummary <- collapsibleTreeSummary(
+ Geography,
+ hierarchy = c("continent", "type", "country")
+)
+
+test_that("left margins are the correct size - tibble", {
+ expect_gt(geo$x$options$margin$left, 50)
+ expect_gt(geoSummary$x$options$margin$left, 50)
+ expect_lt(geo$x$options$margin$left, 100)
+ expect_lt(geoSummary$x$options$margin$left, 100)
+})
+
+test_that("right margins are the correct size - tibble", {
+ expect_gt(geo$x$options$margin$right, 250)
+ expect_gt(geoSummary$x$options$margin$right, 250)
+ expect_lt(geo$x$options$margin$right, 300)
+ expect_lt(geoSummary$x$options$margin$right, 300)
+})