According to the post How to display scatter plot with R Packages:svgPanZoom? I tried to replicate a zoomable plot in R shiny. Can someone help me with my code? Why can't I reproduce this code?
library(shiny)
library(svglite)
library(svgPanZoom)
# Define UI ----
ui <- shinyUI(bootstrapPage(
# App title ----
headerPanel("Cyl vtree"),
# Main panel for displaying outputs ----
svgPanZoom(
svglite:::inlineSVG(
show(p)
),
controlIconsEnabled = T
)
))
# Define server logic to plot ----
server <- function(input, output) {
output$main_plot <- renderSvgPanZoom({
p <- ggplot(mtcars, aes(x = cyl, y = mpg)) + geom_point()
svgPanZoom(p, controlIconsEnabled = T)
})
}
shinyApp(ui, server)
svgPanZoomOutput
is missing in your UI to bind svgpanzoom to shinysvgPanZoom
in UI which only belongs to renderSvgPanZoom
in server?svgPanZoom
library(shiny)
library(svglite)
library(svgPanZoom)
library(ggplot2)
library(gridSVG)
# Define UI ----
ui <- shinyUI(bootstrapPage(
# App title ----
headerPanel("Cyl vtree"),
# Main panel for displaying outputs ----
svgPanZoomOutput(outputId = "main_plot")
))
# Define server logic to plot ----
server <- function(input, output) {
output$main_plot <- renderSvgPanZoom({
p <- ggplot(mtcars, aes(x = cyl, y = mpg)) + geom_point()
svgPanZoom(p, controlIconsEnabled = T)
})
}
shinyApp(ui, server)