Create interactive sunburst chart with the 'd2b' charting library.

  data = NULL,
  colors = NULL,
  valueField = "size",
  tooltip = NULL,
  breadcrumbs = NULL,
  rootLabel = NULL,
  showLabels = FALSE,
  width = NULL,
  height = NULL,
  elementId = NULL



data in csv source,target form or in nested d3 JSON hierarchy with `name:..., children:[];`. list, character, or connection data will be assumed to be JSON. data.frame data will be assumed to be csvdata and converted to JSON by sunburstR:::csv_to_hier().


vector of strings representing colors as hexadecimal for manual colors. If you want precise control of colors, supply a list with range and/or domain. For advanced customization, supply a JavaScript function.


character for the field to use to calculate size. The default value is "size".


list of options for customizing the tooltip. See the helper function sund2bTooltip for more information.


list of options for customizing the breadcrumb. See the helper function sund2bBreadcrumb for more information.


character to label root node something other than 'root'.


logical to show labels on the slices. The default is FALSE.

height, width

height and width of sunburst htmlwidget containing div specified in any valid CSS size unit.


string id as a valid CSS element id.


if(interactive()){ # The sund2b() API mirrors sunburst() with fewer arguments. library(sunburstR) # use a sample of the sequences csv data sequences <- read.csv( system.file("examples/visit-sequences.csv",package="sunburstR") ,header = FALSE ,stringsAsFactors = FALSE )[1:200,] # create a d2b sunburst sund2b(sequences) # show labels sund2b(sequences, showLabels = TRUE) # change the colors # using d3.js categorical color scheme sund2b( sequences, colors = htmlwidgets::JS("d3.scaleOrdinal(d3.schemeCategory20b)") ) } if (FALSE) { # using RColorBrewer palette sund2b( sequences, colors = list(range = RColorBrewer::brewer.pal(9, "Set3")) ) # using a color column from the R dataset # treemap has an amazing treecolors ability library(treemap) library(d3r) rhd <- tm <- treemap( rhd, index = paste0("index", 1:3), vSize = "x", draw = FALSE )$tm sund2b( d3_nest(tm, value_cols = colnames(tm)[-(1:3)]), colors = htmlwidgets::JS( # yes this is a little different, so please pay attention # "function(d) {return d.color}" will not work "function(name, d){return d.color || '#ccc';}" ), valueField = "vSize" ) # use sund2b in Shiny library(shiny) ui <- sund2bOutput("sun") server <- function(input, output, session) { output$sun <- renderSund2b({ sund2b(sequences) }) } shinyApp(ui, server) }