Skip to content

Instantly share code, notes, and snippets.

@rpodcast
Last active Nov 4, 2019
Embed
What would you like to do?
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)
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