Download images in Shiny
Đang mở
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- R
- Star
- 2.7k
- Fork
- 641
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
Hi! I'm using plotly in a shiny. When I want to download the image, first I used export, it works, but it returns a message "use orca", but it was also superseded by kaleido(). So I use save_image(), and it return an error .
Warning: Error in py_run_string_impl: File "<string>", line 1
open('C:\Users\limbo\AppData\Local\Temp\RtmpkD8Zlu\file1d5837d66529.png', 'wb').write(scope_1d58780818d2.transform(sys.modules['json'].loads(scope_1d58780818d2._last_plot), format='png', width=None, height=None, scale=None))
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
[No stack trace available]
my shiny
library(shiny)
library(plotly)
ui <- fluidPage(
plotlyOutput("plot"),
downloadButton("download", "Download")
)
server <- function(input, output, session) {
p <- reactive({
a <- ggplot(iris,
aes(x = Species,
y = Sepal.Length)
) +
geom_boxplot() +
theme_bw()
a <- ggplotly(a)
a
})
output$plot <- renderPlotly(p())
output$download <- downloadHandler(
filename = function(){
paste0(paste0("test",
Sys.Date()),
".png")
},
content = function(file){
plotly::save_image(p(), file = file)
}
)
}
shinyApp(ui, server)
What can I do about that? Thanks!
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách chạy ví dụ Shiny được cung cấp trên Windows, tập trung vào downloadHandler() và plotly::save_image() với kaleido. Theo dõi lệnh gọi Python được tạo ra và so sánh nó với đường dẫn tạm thời hiển thị trong lỗi; hoàn thành khi ví dụ tải xuống PNG mà không gặp lỗi unicodeescape.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- plotly, python, r
- Lĩnh vực
- data-visualization
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100