在闪亮的应用程序中截取特定情节的屏幕截图
Take screenshot of specific plot in a shiny app
如何在闪亮的应用程序中截取特定图表而不是整个图表的屏幕截图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)
您可以使用 selector
参数:
By default, the entire page is captured. If you'd like to capture a specific part of the screen, you can use the selector parameter to specify a CSS selector. For example, if you have a plot with ID myplot then you can use screenshot(selector="#myplot")
在这种情况下:
screenshot(selector="#plot")
如何在闪亮的应用程序中截取特定图表而不是整个图表的屏幕截图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)
您可以使用 selector
参数:
By default, the entire page is captured. If you'd like to capture a specific part of the screen, you can use the selector parameter to specify a CSS selector. For example, if you have a plot with ID myplot then you can use screenshot(selector="#myplot")
在这种情况下:
screenshot(selector="#plot")