简体   繁体   English

手机上ggplot2的闪亮下载按钮

[英]Shiny downloadButton for ggplot2 on mobile

I'm having issues using downloadButton on mobile (iOS), but no issues on desktop.我在移动设备 (iOS) 上使用 downloadButton 时遇到问题,但在桌面上没有问题。 Here is the server code:这是服务器代码:

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

#PLOT STUFF HERE

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

dev.off()

 } 
)

and here is the UI code:这是用户界面代码:

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

When I click the download button on desktop, the plot downloads perfectly.当我点击桌面上的下载按钮时,情节下载完美。 But when I try to do it on mobile (iOS) this happens: weird code from download但是当我尝试在移动设备(iOS)上执行此操作时,会发生这种情况:来自下载的奇怪代码

You should add the add contentType = 'image/png' to your downloadHandler .您应该将 add 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'
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM