R/golwidget.R

Defines functions golwidget golOutput renderGol

#' @import htmlwidgets
#' @export
golwidget <- function(data, width = NULL, height = NULL) {

  # create the data to pass to the playing field
  x <- list(data = data)

  # create the widget
  htmlwidgets::createWidget("golwidget", x, width = width, height = height)
}

#' @import htmlwidgets
#' @export
golOutput <- function(outputId, width = "100%", height = "400px") {
  htmlwidgets::shinyWidgetOutput(outputId, "golwidget", width, height,
                                 package = "golwidget")
}

#' @import htmlwidgets
#' @export
renderGol <- function(expr, env = parent.frame(), quoted = FALSE) {
  if (!quoted) { expr <- substitute(expr) } # force quoted
  htmlwidgets::shinyRenderWidget(expr, golOutput, env, quoted = TRUE)
}
jmcphers/golwidget documentation built on May 19, 2019, 1:52 p.m.