timelyportfolio / sunburstR

R htmlwidget for interactive sunburst plots
http://timelyportfolio.github.io/sunburstR/articles/sunburst-2-0-0.html
Other
210 stars 123 forks source link

custom sund2bBreadcrumb outputs text in all upper case #119

Open missuse opened 7 months ago

missuse commented 7 months ago

Hi and thanks for developing a great package!

I am trying to customize the breadcrumbs within sunburstR::sund2b and it seems the text is always in upper case. Could you please show an example how to change this behavior:

library(sunburstR)

df <- data.frame(seq = c("A","B","C"),
                            size = c(13.4, 9.22, 7.111))

js_bread <- "function(nodedata, size, percent) {
                    var roundedSize = Math.round(size * 100) / 100;
                    var roundedPercent = Math.round(percent * 100 * 10) / 10 ;

                    var sizeText = roundedSize + ' h';

                    var breadcrumb = '<div style=\"text-align: center; font-weight: bold; \">' + nodedata.name + '</div>';
                    breadcrumb += '<div style=\"display: flex; justify-content: space-between;\">';
                    breadcrumb += '<div style=\"flex-grow: 1; font-size: 14px;\">' + sizeText + '</div>';
                    breadcrumb += '<div style=\"text-align: right; font-size: 14px; \">' + roundedPercent + '%' + '</div>';
                    breadcrumb += '</div>';

                   return breadcrumb;
              }
            "
sunburstR::sund2b(
  df,
  showLabels = TRUE,
  breadcrumbs = sunburstR::sund2bBreadcrumb(
    html = htmlwidgets::JS(js_bread))
  )

output is image and "H" is in uppercase.

Thank you!

hammerPC commented 7 months ago

您好,信件我已收到,将会尽快回复。   王鹏超