sunburstR
sunburstR copied to clipboard
legend font
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
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)