No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

53 líneas
1.5KB

  1. #' <Add Title>
  2. #'
  3. #' <Add Description>
  4. #'
  5. #' @import htmlwidgets
  6. #'
  7. #' @export
  8. frappeChart <- function(message, width = NULL, height = NULL, elementId = NULL) {
  9. # forward options using x
  10. x = list(
  11. message = message
  12. )
  13. # create widget
  14. htmlwidgets::createWidget(
  15. name = 'frappeChart',
  16. x,
  17. width = width,
  18. height = height,
  19. package = 'frappeCharts',
  20. elementId = elementId
  21. )
  22. }
  23. #' Shiny bindings for frappeChart
  24. #'
  25. #' Output and render functions for using frappeChart within Shiny
  26. #' applications and interactive Rmd documents.
  27. #'
  28. #' @param outputId output variable to read from
  29. #' @param width,height Must be a valid CSS unit (like \code{'100\%'},
  30. #' \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a
  31. #' string and have \code{'px'} appended.
  32. #' @param expr An expression that generates a frappeChart
  33. #' @param env The environment in which to evaluate \code{expr}.
  34. #' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
  35. #' is useful if you want to save an expression in a variable.
  36. #'
  37. #' @name frappeChart-shiny
  38. #'
  39. #' @export
  40. frappeChartOutput <- function(outputId, width = '100%', height = '400px'){
  41. htmlwidgets::shinyWidgetOutput(outputId, 'frappeChart', width, height, package = 'frappeCharts')
  42. }
  43. #' @rdname frappeChart-shiny
  44. #' @export
  45. renderFrappeChart <- function(expr, env = parent.frame(), quoted = FALSE) {
  46. if (!quoted) { expr <- substitute(expr) } # force quoted
  47. htmlwidgets::shinyRenderWidget(expr, frappeChartOutput, env, quoted = TRUE)
  48. }