Empty event payload for plotly_selected when using ggplotly on geom_tile
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ả
In the example provided below, the heatmap is selectable on the x but the corresponding event payload is empty.
Expected: The selection should be part of the event payload. This works for other plots, e.g. see commented out histogram example in the provided code.
# Source https://rdrr.io/cran/plotly/src/inst/examples/shiny/event_data/app.R
library(plotly)
library(nycflights13)
library(shiny)
library(dplyr)
library(lubridate)
flights = flights %>% mutate(departure = make_datetime(year, month, day, hour, minute))
ui <- fluidPage(
radioButtons("plotType", "Plot Type:", choices = c("ggplotly", "plotly")),
plotlyOutput("plot"),
verbatimTextOutput("brushing"),
)
server <- function(input, output, session) {
output$plot <- renderPlotly({
p <- if (identical(input$plotType, "ggplotly")) {
## works and gives correct results
# ggplotly(ggplot(flights, aes(x = departure)) + geom_histogram())
## gives empty event data
ggplotly(ggplot(head(flights, 10000), aes(x = departure, carrier, fill=arr_time)) + geom_tile())
} else {
plot_ly(mtcars, x = ~mpg, y = ~wt, customdata = nothing)
}
p %>%
layout(dragmode = "select") %>%
# see https://webinars.cpsievert.me/20180220/#13
event_register("plotly_selected")
})
observeEvent(event_data("plotly_selected"), {
d <- event_data("plotly_selected")
print("caught event from here as well")
print(paste(str(d)))
})
}
shinyApp(ui, server)
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 với ví dụ Shiny có thể tái hiện trong inst/examples/shiny/event_data/app.R và so sánh trường hợp ggplotly với geom_tile với các nhánh histogram và plot_ly đang hoạt động. Theo dõi event_data("plotly_selected") và event_register("plotly_selected"); hoàn thành khi việc chọn tile trả về một payload không rỗng giống như các biểu đồ có thể chọn khác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- 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