timelyportfolio/sunburstR

Sund2b legend wrapping

tykerx opened this issue · 2 comments

Screen_Shot_2019-07-23_at_10_28_05_AM

Hello!

I'm having an issue where my legend is wrapping text due to the root being a large number: I've included an image showing what I'm experiencing. Is there a solution to this that I am somehow missing?

Thank you!

@tykerx thanks for posting the issue and using sunburstR.

Using CSS

A simple solution would be to apply some CSS.

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,]

# make the values bigger for demonstration
sequences$V2 <- sequences$V2 * 1000

# create a d2b sunburst
htmlwidgets::prependContent(
  sund2b(sequences, elementId = "my-sunburst"), # add an id so css specificity will prefer,
  htmltools::tags$style("#my-sunburst .d2b-sunburst-breadcrumb, #my-sunburst .d2b-sunburst-value {font-size: 8pt;}") # our id added below
)

image

Multiple Sunbursts with CSS

If you are using multiple d2b sunbursts in a chart and you don't want to use prependContent on each, you could add style to all with something like this in rmarkdown or shiny.

tags$head(
  tags$style(".html-widget .d2b-sunburst-breadcrumb, .html-widget .d2b-sunburst-value {font-size: 8pt;})
)

More Advanced

For ultimate control of the sunburst, I could add the functionality to control the breadcrumb as demonstrated in this example. This currently is not supported, but I can add if necessary.

@tykerx, going to close. Feel free to reopen if the solution does not work for you. Thanks!