HTML documents including plotly plots are not reproducible
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ả
I believe it is known that the value of plotly::plot_ly(x = 1, y = 1)$x$cur_data is hard to reproduce, compare https://github.com/plotly/plotly.R/issues/1048. Some work has been done in #1379 towards use in shinytest at least.
I am also using shinytest, but in my app, users are downloading HTML files with plotly plots generated using rmarkdown::render(). So these files are still non-reproducible because I cannot seem to use renderPlotly() inside rmarkdown::render(). To see the problem:
bug.Rmd:
---
output: html_document
---
```{r}
plotly::plot_ly(x = 1, y = 1)
```
Then run R -q -s -e 'rmarkdown::render("bug.Rmd")' and see the value of cur_data in bug.html change every time you regenerate it.
I see two options:
- I could replicate the logic of
https://github.com/plotly/plotly.R/blob/bab01af316673e35d8314129178bfb27eed27fe7/R/shiny.R#L46-L53
inside bug.Rmd, like this:
However, this breaks the plot. Any way I can make this work?p <- plotly::plot_ly(x = 1, y = 1) p$x$attrs <- NULL # and a few more p - I have also tried putting this inside
bug.Rmd:
butshiny::snapshotPreprocessOutput( plotly::plot_ly(x = 1, y = 1), function(value) { # https://github.com/plotly/plotly.R/blob/3d49fbc5897703d58b/R/shiny.R#L68 json <- jsonlite::from_JSON(value) json$x <- json$x[setdiff(names(json$x), c("visdat", "cur_data", "attrs"))] # https://github.com/plotly/plotly.R/blob/3d49fbc589/R/utils.R#L1020-L1025 jsonlite::toJSON(json, digits = 50, auto_unbox = TRUE, force = TRUE, null = "null", na = "null", time_format = "%Y-%m-%d %H:%M:%OS6" ) } )rmarkdown::render()seemed to ignore it, even insideshinytest(or did I do anything wrong there)? - One could amend #1365 to take into account a hash of the current plot serialization to avoid generating identical IDs even if the external seed is reset to the same values externally. This would avoid the need for
tempfile().
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
Tái hiện vấn đề với bug.Rmd và R -q -s -e 'rmarkdown::render("bug.Rmd")', sau đó so sánh giá trị của cur_data trong bug.html giữa các lần render. Đọc logic được tham chiếu trong R/shiny.R và R/utils.R, cùng với các issue liên quan #1048, #1379 và #1365. Được coi là hoàn tất khi các tài liệu HTML được render bằng rmarkdown::render() tạo ra dữ liệu plot có thể tái lập mà không làm hỏng plot.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, r
- Lĩnh vực
- data-visualization, web-dev
- Loại issue
- Lỗi
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100