Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create standard safetyGraphics shiny binding #102

Open
jwildfire opened this issue Mar 12, 2022 · 0 comments
Open

Create standard safetyGraphics shiny binding #102

jwildfire opened this issue Mar 12, 2022 · 0 comments

Comments

@jwildfire
Copy link
Contributor

Would it make sense to also add Shiny binding functions like in {safetyGraphics} prepareChart function? Something like below?

sgV2's chartsTab module is great, however, the following binding might add flexibility to drop a widget to a Shiny app without having to use tab UI.

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

#' @export
meta_renderWidget <- function(expr, widgetName, env = parent.frame(), quoted = FALSE) {
  
  widgetOutput <- function(outputId, width = "100%", height = "400px") {
    htmlwidgets::shinyWidgetOutput(outputId, widgetName, width, height, package="safetyCharts")
  }
  
  if (!quoted) { expr <- substitute(expr) } # force quoted
  
  params <- list(
    expr             = expr, 
    outputFunction   = widgetOutput, 
    env              = env, 
    quoted           = quoted,
    cacheHint        = "auto"
  )
  
  do.call( htmlwidgets::shinyRenderWidget, params)
}

Originally posted by @xni7 in #101 (review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant