R/d3plus-wrappers.R

# some functions to reduce JS complexity inside Shiny code

#' @export
d3p_JSarg <- function(arg = NULL) {
  htmlwidgets::JS(sprintf("function(d) { return d.%s; }", arg))
}

#' @export
d3p_titleCase <- function(arg = NULL) {
  htmlwidgets::JS(
    sprintf("function(d) {
      var txt = d.%s;
      return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
      }", arg
    )
  )
}

#' @export
d3p_footer <- function(arg = NULL) {
  htmlwidgets::JS(
    sprintf("function(d) {
      return \"<sub class='tooltip-footer'>%s</sub>\";
    }", arg
    )
  )
}
pachamaltese/d3plus2 documentation built on June 5, 2019, 5:08 a.m.