Shinyscreenshot 仅捕获闪亮应用程序中选定 svg 文件的一部分
Shinyscreenshot captures only a part of selected svg file in a shiny app
我有下面这个闪亮的应用程序,我想从中截取 svg 文件的屏幕截图,但它只捕获了它的上角。
library(shiny)
library(DiagrammeR)
library(tidyverse)
# probably don't need all of these:
library(DiagrammeRsvg)
library(svglite)
library(svgPanZoom)
library(rsvg)
library(V8)# only for svg export but also does not work
library(xml2)
library(magrittr)
library(shinyscreenshot)
ui <- fluidPage(
tags$head(
tags$script(src = "https://unpkg.com/panzoom@9.4.0/dist/panzoom.min.js")
),
grVizOutput("grr",width = "100%",height = "90vh"),
actionButton("go", "Take a screenshot"),
tags$script(
HTML('panzoom($("#grr")[0])')
)
)
server <- function(input, output) {
observeEvent(input$go, {
screenshot(selector="#grr")
})
reactives <- reactiveValues()
observe({
reactives$graph <- render_graph(create_graph() %>%
add_n_nodes(n = 2) %>%
add_edge(
from = 1,
to = 2,
edge_data = edge_data(
value = 4.3)))
})
output$grr <-
renderGrViz(reactives$graph
)
}
# Run the application
shinyApp(ui = ui, server = server)
您可以改用 capture 包。运行良好,但您不会获得 SVG 图像。
library(shiny)
library(DiagrammeR)
library(magrittr)
library(capture)
ui <- fluidPage(
tags$head(
tags$script(src = "https://unpkg.com/panzoom@9.4.0/dist/panzoom.min.js")
),
grVizOutput("grr", width = "100%", height = "90vh"),
capture(
selector = "#grr",
filename = "myimage.png",
icon("camera"), "Take screenshot"
),
tags$script(
HTML('panzoom($("#grr")[0])')
)
)
server <- function(input, output) {
reactives <- reactiveValues()
observe({
reactives$graph <- render_graph(create_graph() %>%
add_n_nodes(n = 2) %>%
add_edge(
from = 1,
to = 2,
edge_data = edge_data(
value = 4.3)))
})
output$grr <- renderGrViz(reactives$graph)
}
# Run the application
shinyApp(ui = ui, server = server)
我有下面这个闪亮的应用程序,我想从中截取 svg 文件的屏幕截图,但它只捕获了它的上角。
library(shiny)
library(DiagrammeR)
library(tidyverse)
# probably don't need all of these:
library(DiagrammeRsvg)
library(svglite)
library(svgPanZoom)
library(rsvg)
library(V8)# only for svg export but also does not work
library(xml2)
library(magrittr)
library(shinyscreenshot)
ui <- fluidPage(
tags$head(
tags$script(src = "https://unpkg.com/panzoom@9.4.0/dist/panzoom.min.js")
),
grVizOutput("grr",width = "100%",height = "90vh"),
actionButton("go", "Take a screenshot"),
tags$script(
HTML('panzoom($("#grr")[0])')
)
)
server <- function(input, output) {
observeEvent(input$go, {
screenshot(selector="#grr")
})
reactives <- reactiveValues()
observe({
reactives$graph <- render_graph(create_graph() %>%
add_n_nodes(n = 2) %>%
add_edge(
from = 1,
to = 2,
edge_data = edge_data(
value = 4.3)))
})
output$grr <-
renderGrViz(reactives$graph
)
}
# Run the application
shinyApp(ui = ui, server = server)
您可以改用 capture 包。运行良好,但您不会获得 SVG 图像。
library(shiny)
library(DiagrammeR)
library(magrittr)
library(capture)
ui <- fluidPage(
tags$head(
tags$script(src = "https://unpkg.com/panzoom@9.4.0/dist/panzoom.min.js")
),
grVizOutput("grr", width = "100%", height = "90vh"),
capture(
selector = "#grr",
filename = "myimage.png",
icon("camera"), "Take screenshot"
),
tags$script(
HTML('panzoom($("#grr")[0])')
)
)
server <- function(input, output) {
reactives <- reactiveValues()
observe({
reactives$graph <- render_graph(create_graph() %>%
add_n_nodes(n = 2) %>%
add_edge(
from = 1,
to = 2,
edge_data = edge_data(
value = 4.3)))
})
output$grr <- renderGrViz(reactives$graph)
}
# Run the application
shinyApp(ui = ui, server = server)