【问题标题】:R svgPanZoom within shinyApp display different in the Web and RstudioShinyApp中的R svgPanZoom在Web和Rstudio中显示不同
【发布时间】:2018-10-09 12:22:03
【问题描述】:

我使用带有包 svgPanZoom、svglite、ggplot2 和闪亮的 R 绘制图片。但是,它可以在 Rstudio 上正确显示,但不能在 Web 上显示。有什么办法可以解决吗?详细请运行以下代码。

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

data<-data.frame(x=1:50,y=1:50)
x_position<-1:50
y_position<-1:50
ui <- pageWithSidebar(
  headerPanel(""),
  sidebarPanel(),
  mainPanel(

    column(width=12,svgPanZoomOutput(outputId = "main_plot",width=600,height=450))

))

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

    svgPanZoom(
      svglite:::inlineSVG(show(p))
      , controlIconsEnabled = T)
  })
})

shinyApp(ui,server)

R 工作室:

网站:

【问题讨论】:

  • 是svglite:::inlineSVG的问题,不知道怎么处理。

标签: r svg shiny svgpanzoom


【解决方案1】:

最后,我尝试了“SVGAnnotation”包,幸运地解决了这个问题。

【讨论】:

    【解决方案2】:

    我遇到了类似的问题,并且很容易解决。这是来自 ui.R 的 sn-ps:

    svgPanZoomOutput(outputId = "betaPlot", height = "800px")
    

    和服务器.R

    p = ggplot(blah blah)
    
        svgPanZoom(
      svglite::stringSVG(print(p), standalone = F),
      controlIconsEnabled = T, viewBox = FALSE
    )
    

    外部浏览器需要viewBox = FALSE,需要在ui.R中调整图形高度,否则控件不显示。

    显然是加载库(svglite)和库(svgPanZoom)

    好吧,无论如何它对我有用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-30
      • 1970-01-01
      • 1970-01-01
      • 2017-09-25
      • 1970-01-01
      • 2015-09-16
      • 1970-01-01
      相关资源
      最近更新 更多