diff --git a/DESCRIPTION b/DESCRIPTION index ef80555..83886a0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: sunburstR Type: Package -Title: 'Htmlwidget' for 'Kerry Rodden' 'd3.js' Sequence and 'd2b' Sunburst +Title: Sunburst 'Htmlwidget' Version: 2.1.3 Date: 2019-10-07 Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 634b961..c4c5a76 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # sunburstR 2.1.3 * add breadcrumb customization to d2b; (see [issue 92](https://github.com/timelyportfolio/sunburstR/issues/92)) +* add argument to allow user to change root label (see [issue 96](https://github.com/timelyportfolio/sunburstR/issues/96)) # sunburstR 2.1.2 diff --git a/R/d2b.R b/R/d2b.R index 45bbede..0264d24 100644 --- a/R/d2b.R +++ b/R/d2b.R @@ -17,6 +17,7 @@ #' function \code{\link{sund2bTooltip}} for more information. #' @param breadcrumbs \code{list} of options for customizing the breadcrumb. See the helper #' function \code{\link{sund2bBreadcrumb}} for more information. +#' @param rootLabel \code{character} to label root node something other than 'root'. #' @param height,width height and width of sunburst htmlwidget containing div #' specified in any valid \code{CSS} size unit. #' @param elementId string id as a valid \code{CSS} element id. @@ -32,6 +33,7 @@ sund2b <- function( valueField = "size", tooltip = NULL, breadcrumbs = NULL, + rootLabel = NULL, width = NULL, height = NULL, elementId = NULL ) { @@ -71,7 +73,8 @@ sund2b <- function( ), options = list( colors = colors, - valueField = valueField + valueField = valueField, + rootLabel = rootLabel ) ) diff --git a/docs/CONDUCT.html b/docs/CONDUCT.html index eb3219e..2b6520c 100644 --- a/docs/CONDUCT.html +++ b/docs/CONDUCT.html @@ -60,7 +60,7 @@
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index fb749e2..aace347 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -60,7 +60,7 @@ diff --git a/docs/articles/index.html b/docs/articles/index.html index 3ca8dd9..9fbcfe7 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -60,7 +60,7 @@ diff --git a/docs/articles/sunburst-2-0-0.html b/docs/articles/sunburst-2-0-0.html index 840ee81..3676229 100644 --- a/docs/articles/sunburst-2-0-0.html +++ b/docs/articles/sunburst-2-0-0.html @@ -30,7 +30,7 @@ @@ -78,14 +78,14 @@ - +vignettes/sunburst-2-0-0.Rmd
sunburst-2-0-0.Rmd
Let’s get started by loading some packages and making some simple data to use throughout the post.
+#> [1] '2.1.3'Simple data should suffice for these examples.
library(htmltools)
#> Warning: package 'htmltools' was built under R version 3.4.4
@@ -181,7 +181,7 @@
)
NEWS.md
- Advanced Customization of 'd2b' Breadcrumb
sund2b(data = NULL, colors = NULL, valueField = "size", - tooltip = NULL, width = NULL, height = NULL, elementId = NULL)+ tooltip = NULL, breadcrumbs = NULL, rootLabel = NULL, + width = NULL, height = NULL, elementId = NULL)
|
+ |||||||
breadcrumbs | +
|
+ ||||||
---|---|---|---|---|---|---|---|
rootLabel | +
|
+ ||||||
height, width | height and width of sunburst htmlwidget containing div diff --git a/docs/reference/sund2bBreadcrumb.html b/docs/reference/sund2bBreadcrumb.html new file mode 100644 index 0000000..d8193c1 --- /dev/null +++ b/docs/reference/sund2bBreadcrumb.html @@ -0,0 +1,219 @@ + + + + + + + + +
+
+
+
+
+
+
+
diff --git a/docs/reference/sund2bTooltip.html b/docs/reference/sund2bTooltip.html
index 9303ddd..f83b28d 100644
--- a/docs/reference/sund2bTooltip.html
+++ b/docs/reference/sund2bTooltip.html
@@ -63,7 +63,7 @@
@@ -175,11 +175,7 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Advanced Customization of 'd2b' Breadcrumb + +sund2bBreadcrumb(enabled = NULL, html = NULL, orient = NULL)+ + Arguments+
Value+ +
Examples++ Examp ,stringsAsFactors = FALSE )[1:200,] -# create a d2b sunburst -sund2b(sequences) - -# change the colors -# using d3.js categorical color scheme +# change the tooltip sund2b( sequences, tooltip = sund2bTooltip( diff --git a/inst/htmlwidgets/sund2b.js b/inst/htmlwidgets/sund2b.js index 39307cd..ed68d54 100644 --- a/inst/htmlwidgets/sund2b.js +++ b/inst/htmlwidgets/sund2b.js @@ -67,6 +67,10 @@ HTMLWidgets.widget({ return d[x.options.valueField || "size"]; }); + if(x.options.hasOwnProperty("rootLabel") && x.options.rootLabel !== null) { + x.data.root.label = x.options.rootLabel; + } + d3.select(el).datum(x.data) .transition() .call(sunburst.advanced); diff --git a/man/sund2b.Rd b/man/sund2b.Rd index ccb3304..3d8b180 100644 --- a/man/sund2b.Rd +++ b/man/sund2b.Rd @@ -5,8 +5,8 @@ \title{Sunburst Using 'd2b'} \usage{ sund2b(data = NULL, colors = NULL, valueField = "size", - tooltip = NULL, breadcrumbs = NULL, width = NULL, height = NULL, - elementId = NULL) + tooltip = NULL, breadcrumbs = NULL, rootLabel = NULL, + width = NULL, height = NULL, elementId = NULL) } \arguments{ \item{data}{data in csv source,target form or in @@ -29,6 +29,8 @@ function \code{\link{sund2bTooltip}} for more information.} \item{breadcrumbs}{\code{list} of options for customizing the breadcrumb. See the helper function \code{\link{sund2bBreadcrumb}} for more information.} +\item{rootLabel}{\code{character} to label root node something other than 'root'.} + \item{height, width}{height and width of sunburst htmlwidget containing div specified in any valid \code{CSS} size unit.} diff --git a/man/sund2bBreadcrumb.Rd b/man/sund2bBreadcrumb.Rd index 7f7aa72..70380e3 100644 --- a/man/sund2bBreadcrumb.Rd +++ b/man/sund2bBreadcrumb.Rd @@ -35,6 +35,14 @@ sequences <- read.csv( ,stringsAsFactors = FALSE )[1:200,] +# disable the breadcrumb +sund2b( + sequences, + breadcrumbs = sund2bBreadcrumb( + enabled = FALSE + ) +) + # change the breadcrumb content sund2b( sequences, |