Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

legend font #109

Open
ssalimi opened this issue Dec 19, 2020 · 1 comment
Open

legend font #109

ssalimi opened this issue Dec 19, 2020 · 1 comment

Comments

@ssalimi
Copy link

ssalimi commented Dec 19, 2020

Hello,
We developed a SunbusrtR code for ShinyApp but I do not know how to change the legend font. The code is as below:

sunburst(dat_lst[[2]], 
         # make the breadcrumbs smaller but doesn't wrap the long tails
         # breadcrumb = list(w=25, h=15, s=3, t=2),
         legend = list(w=27, h=10, s=3)
         ) 

How I can add the legend font size here?
Thanks

@cjyetman
Copy link
Collaborator

I don't believe that sunburstR has a built-in option to adjust the font size of the legend, however, you could achieve this by using htmlwidgets::onRender() to inject JavaScript when the sunburst is rendered that sets the font size (as well as other styles potentially) of the legend, for example...

library(sunburstR)

csv_path <- system.file("examples/visit-sequences.csv", package = "sunburstR")
sequences <- read.csv(csv_path, header = FALSE, stringsAsFactors = FALSE)[1:100, ]

sunburst_obj <- sunburst(sequences)

onrender_js <- 
  'function(el) { 
    [...el.querySelectorAll(".sunburst-legend svg text")].forEach((text) => { text.style.fontSize = "22px"; }); 
  }'

htmlwidgets::onRender(sunburst_obj, onrender_js)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants