渲染图像不输出闪亮

时间:2020-08-28 09:54:07

标签: shiny

  output$plot <- renderImage({
  
outfile <- tempfile(fileext = '.png')
png(outfile, width = 400, height = 300)
venn.diagram(
  x = list(
    T = T,
    I = I
  ),
  main = "Venn Diagram ",
  filename =outfile, output=TRUE,
  lwd = 2,na = "remove",
  fill = c("orange", "blue"),
  alpha = c(0.5,0.5),
  label.col = "black",
  cex=1.5,
  fontface = "plain",
  cat.col = c("cornflowerblue", "pink"),
  cat.cex = 1.5,
  cat.fontfamily = "serif",
  cat.fontface = "plain",
  cat.dist = c(0.05, 0.05),
  cat.pos = c(-20, 14),
  cat.default.pos = "text",
  scaled = FALSE
)
dev.off()

list(src = outfile,
     contentType = 'image/png',
     width = 400,
     height = 300,
     alt = "This is alternate text")
}, deleteFile = TRUE)

我正在尝试使用此代码绘制维恩图。但是它仅显示“这是替代文本”,并且不会在应用程序上输出任何图像,任何想法?

2 个答案:

答案 0 :(得分:1)

尝试创建如下所示的反应图

output$plot <- renderImage({
    vennd <- reactive({venn.diagram(
      x = list(
        T = T,
        I = I
      ),
      main = "Venn Diagram ",
      filename =outfile, output=TRUE,
      lwd = 2,na = "remove",
      fill = c("orange", "blue"),
      alpha = c(0.5,0.5),
      label.col = "black",
      cex=1.5,
      fontface = "plain",
      cat.col = c("cornflowerblue", "pink"),
      cat.cex = 1.5,
      cat.fontfamily = "serif",
      cat.fontface = "plain",
      cat.dist = c(0.05, 0.05),
      cat.pos = c(-20, 14),
      cat.default.pos = "text",
      scaled = FALSE
    )
    })
    outfile <- tempfile(fileext = '.png')
    png(outfile, width = 400, height = 300)
    vennd()
    dev.off()
    
    list(src = outfile,
         contentType = 'image/png',
         width = 400,
         height = 300,
         alt = "This is alternate text")
  }, deleteFile = TRUE)

答案 1 :(得分:0)

<style>
  /* Color of active silder dot */
    .slick-dots li.slick-active button:before {
      color: {{section.settings.colorDotActive }};
    }
</style>

需要添加imagetype =“ png”和type =“ cairo”谢谢@YBS