Skip to content

Instantly share code, notes, and snippets.

@rpodcast
Last active November 4, 2019 14:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpodcast/6c33ee09a16d55569c562f7aa3951088 to your computer and use it in GitHub Desktop.
Save rpodcast/6c33ee09a16d55569c562f7aa3951088 to your computer and use it in GitHub Desktop.
Shiny modules and custom SVG javascript

This app requires the shiny and xml2 packages. Run the gist interactively with the following:

shiny::runGist('6c33ee09a16d55569c562f7aa3951088')
library(shiny)
library(xml2)
mod_image_ui <- function(id) {
ns <- NS(id)
tagList(
fluidRow(
column(
width = 6,
htmlOutput(ns("image_render"))
),
column(
width = 6,
verbatimTextOutput(ns("debugging"))
)
)
)
}
mod_image_server <- function(input, output, session) {
output$image_render <- renderUI({
includeHTML("image.svg")
})
output$debugging <- renderPrint({
ns <- session$ns
input[['region_clicked']]
})
}
ui <- fluidPage(
mod_image_ui("mod1")
)
server <- function(input, output, session) {
callModule(mod_image_server, "mod1")
}
shinyApp(ui, server)
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment