How do I take a screenshot of a specific plotly chart in a shiny app and not the whole UI?
library(shiny)
library(shinyscreenshot)
library(plotly)
ui <- fluidPage(
plotlyOutput("plot"),
actionButton("go", "Take a screenshot")
)
server <- function(input, output) {
output$plot<-renderPlotly({
fig <- plot_ly(
x = c("giraffes", "orangutans", "monkeys"),
y = c(20, 14, NA),
name = "SF Zoo",
type = "bar"
)
fig
})
observeEvent(input$go, {
screenshot()
})
}
shinyApp(ui, server)
You could use the
selector
argument:In this case :