ggplot2在手机上的闪亮下载按钮

时间:2018-08-15 03:07:33

标签: r ggplot2 shiny

我在移动版(iOS)上使用downloadButton遇到问题,但在台式机上没有问题。这是服务器代码:

output$npsDown <- downloadHandler(
filename =  function() {
paste("BL", npsPlayerID(), "S", sep="")
},
content = function(file) {

#PLOT STUFF HERE

ggsave(file, plot = plot, device = "jpeg")

dev.off()

 } 
)

这是UI代码:

downloadButton(outputId = "npsDown", label = "Download Chart")

当我单击桌面上的下载按钮时,该图将完美下载。但是,当我尝试在移动设备(iOS)上进行操作时,会发生这种情况:weird code from download

1 个答案:

答案 0 :(得分:1)

您应将添加的contentType = 'image/png'添加到downloadHandler中。

output$npsDown <- downloadHandler(
filename =  function() {
paste("BL", npsPlayerID(), "S", sep="")
},
content = function(file) {

#PLOT STUFF HERE

ggsave(file, plot = plot, device = "jpeg")

dev.off()

 },
  contentType = 'image/png'
)