`selectedpoints` does not function properly when a vector is passed using `plotlyProxy` & `"restyle"`.
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ả
Bug/Unexpected Behavior
When updating a scatter plot's selectedpoints in a Shiny server using "restyle" on a plotlyProxy, single value vectors don't update the graph. E.g., passing c(1) to selectedpoints won't update the graph.
However, if we duplicate this value, e.g., c(1, 1) and pass it to selectedpoints, the 1 point will be selected.
Reproducible example:
# selected points single value incorrect behavior
library(shiny)
ui <- fluidPage(fluidRow(plotly::plotlyOutput("graph"),
DT::DTOutput("table")))
server <- function(input, output, session) {
output$table <- DT::renderDT({
cars
})
output$graph <- plotly::renderPlotly({
plotly::plot_ly(
cars,
x = ~ speed,
y = ~ dist,
selected = list(marker = list(color = "red")),
type = "scatter",
mode = "markers",
source = "graph"
) %>%
plotly::layout(dragmode = "select",
clickmode = "event+select") %>%
plotly::event_register("plotly_selected")
})
plot_proxy <- plotly::plotlyProxy("graph")
table_proxy <- DT::dataTableProxy("table")
selected <-
reactive({
plotly::event_data("plotly_selected", source = "graph")
})
observeEvent(selected(), {
selected <- selected()$pointNumber + 1
table_proxy %>% DT::selectRows(selected)
})
observeEvent(input$table_cell_clicked, {
selected_rows <- input$table_rows_selected - 1
#### comment this conditional to see the bug ####
if (length(selected_rows) == 1) {
selected_rows <- rep(selected_rows, 2)
}
#### end comment this conditional to see the bug ####
plotly::plotlyProxyInvoke(
plotly::plotlyProxy("graph", session),
"restyle",
list(selectedpoints = list(selected_rows)),
0
)
})
}
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 bằng cách chạy ví dụ R Shiny có thể tái lập được cung cấp và so sánh plotlyProxyInvoke với selected_rows chứa c(1) với c(1, 1). Theo dõi việc cập nhật selectedpoints thông qua lệnh gọi "restyle" của plotlyProxy; hoàn thành khi một vector có một giá trị chọn điểm mà không bị trùng lặp.
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ó
- 3/5
- Thời gian dự kiến
- 1-2 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
- 45/100