0

我使用 ggplot2 绘制图片并希望使用 svgPanZoom 包在 shinyApp 中显示它。但是这些sactters消失了。有人知道为什么吗?您可以运行以下代码以获取详细信息:

library(shiny)
library(svglite)
library(svgPanZoom)
library(ggplot2)

data<-data.frame(x=1:10,y=1:10)

ui <- shinyUI(bootstrapPage(

  svgPanZoomOutput(outputId = "main_plot")

))

server = shinyServer(function(input, output) {
  output$main_plot <- renderSvgPanZoom({
    p <- ggplot(data, aes(x = x, y = y)) + geom_point()
    svgPanZoom(p, controlIconsEnabled = T)
  })
})

shinyApp(ui,server)
4

1 回答 1

1

我相信您还需要添加 svglite

library("svglite")

然后用这个替换 svgPanZoom 调用

svgPanZoom(
      svglite:::inlineSVG(
        show(p)
      ),
   controlIconsEnabled = T
)
于 2018-04-27T05:54:27.117 回答