R/gauge.R

Defines functions gauge gaugeOutput renderGauge

#' <Add Title>
#'
#' <Add Description>
#'
#' @import htmlwidgets
#'
#' @export
gauge <- function(data, width = NULL, height = NULL) {

  # forward options using x
  x = list(
    data = data
  )

  # create widget
  htmlwidgets::createWidget(
    name = 'gauge',
    x,
    width = width,
    height = height,
    package = 'gauge'
  )
}

#' Widget output function for use in Shiny
#'
#' @export
gaugeOutput <- function(outputId, width = '100%', height = '400px'){
  shinyWidgetOutput(outputId, 'gauge', width, height, package = 'gauge')
}

#' Widget render function for use in Shiny
#'
#' @export
renderGauge <- function(expr, env = parent.frame(), quoted = FALSE) {
  if (!quoted) { expr <- substitute(expr) } # force quoted
  shinyRenderWidget(expr, gaugeOutput, env, quoted = TRUE)
}
yzhizai/gauge documentation built on May 4, 2019, 8:47 p.m.