Skip to content

Commit

Permalink
patch to allow root label specification with csv_to_hier #114 and l…
Browse files Browse the repository at this point in the history
…et `rootLabel` argument work again with `sund2b()`
  • Loading branch information
timelyportfolio committed Jun 13, 2022
1 parent 9f47439 commit 2d97d12
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: sunburstR
Type: Package
Title: Sunburst 'Htmlwidget'
Version: 2.1.6
Date: 2021-09-19
Version: 2.1.7
Date: 2022-06-12
Authors@R: c(
person(
"Mike", "Bostock"
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# sunburstR 2.1.7

* allow specification of root label in internal `csv_to_hier` converter function
* fix bug where `rootLabel` argument for `sund2b` was not working ; (see [issue 114](https://github.com/timelyportfolio/sunburstR/issues/114))

# sunburstR 2.1.6

* add labels for slices based on https://bl.ocks.org/vasturiano/12da9071095fbd4df434e60d52d2d58d
Expand Down
4 changes: 2 additions & 2 deletions R/converters.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' @keywords internal
csv_to_hier <- function(csv, delim = "-") {
csv_to_hier <- function(csv, delim = "-", rootLabel = "root") {
hier_col <- strsplit(as.character(csv[[1]]), delim)
# determine max length of all the paths to build column names
# issue 107
Expand All @@ -21,5 +21,5 @@ csv_to_hier <- function(csv, delim = "-") {
df <- df[,-1]
}
df$size = csv[[2]]
d3r::d3_nest(df, value_cols = "size")
d3r::d3_nest(df, value_cols = "size", root = rootLabel)
}
2 changes: 1 addition & 1 deletion inst/htmlwidgets/sund2b.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ HTMLWidgets.widget({
}

if(x.options.hasOwnProperty("rootLabel") && x.options.rootLabel !== null) {
x.data.root.label = x.options.rootLabel;
x.data.root.name = x.options.rootLabel;
}

d3.select(el).datum(x.data)
Expand Down

0 comments on commit 2d97d12

Please sign in to comment.