Skip to content
Permalink
Browse files

add ability to use field other than `"size"` with the `valueField` ar…

…gument to `sunburst()`
  • Loading branch information
timelyportfolio committed Apr 7, 2017
1 parent 4499a7c commit 52bfc78cbfb1a8083584370aace863b674b53e32
Showing with 17 additions and 10 deletions.
  1. +6 −1 R/sunburst.R
  2. +1 −1 inst/htmlwidgets/sunburst.js
  3. +0 −1 man/add_shiny.Rd
  4. +1 −2 man/sunburst-shiny.Rd
  5. +9 −5 man/sunburst.Rd
@@ -10,7 +10,10 @@
#' order of the top level hierarchy.
#' @param colors \code{vector} of strings representing colors as hexadecimal for
#' manual colors. If you want precise control of colors, supply a \code{list}
#' with \code{range} and/or \code{domain}.
#' with \code{range} and/or \code{domain}. For advanced customization, supply
#' a JavaScript \code{function}.
#' @param valueField \code{character} for the field to use to calculate size. The default
#' value is \code{"size"}.
#' @param percent \code{logical} to include percentage of total in the explanation.
#' @param count \code{logical} to include count and total in the explanation.
#' @param explanation JavaScript function to define a custom explanation for the center
@@ -39,6 +42,7 @@ sunburst <- function(
, jsondata = NULL
, legendOrder = NULL
, colors = NULL
, valueField = "size"
, percent = TRUE
, count = FALSE
, explanation = NULL
@@ -65,6 +69,7 @@ sunburst <- function(
,options = list(
legendOrder = legendOrder
,colors = colors
,valueField = valueField
,percent = percent
,count = count
,explanation = explanation
@@ -104,7 +104,7 @@ HTMLWidgets.widget({

var partition = d3.layout.partition()
.size([2 * Math.PI, radius * radius])
.value(function(d) { return d.size; });
.value(function(d) { return d[x.options.valueField || "size"]; });

// check for sort function
if(x.options.sortFunction){

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

0 comments on commit 52bfc78

Please sign in to comment.
You can’t perform that action at this time.