Passing `selectedpoints` as an argument to a plot doesn't update the stored selected data.
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, r
- Lĩnh vực
- data-visualization
Hướng nghiên cứu
Bắt đầu bằng cách chạy ví dụ Shiny có thể tái lập và theo dõi các lệnh gọi plotly::event_data và plotly::plotlyProxyInvoke, đặc biệt là thao tác restyle với selectedpoints. Kiểm tra tích hợp JavaScript được plotly.R sử dụng, vì báo cáo xác định kiến thức JavaScript hạn chế là một trở ngại. Được xem là hoàn thành khi selectedpoints được cung cấp trong quá trình xây dựng biểu đồ hoặc restyling được phản ánh trong dữ liệu đã chọn được lưu trữ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug
This problem is also described here:
https://github.com/plotly/dash/issues/2301
This is true when constructing the graph with a selectedpoints argument or when restyling the graph with a selectedpoints argument.
I have been digging into the source code to try to figure out a workaround to this, but my limited knowledge of JavaScript is obscuring the solution.
Reproducible Example
Please see this reproducible example below:
library(shiny)
#' Render the mtcars graphs, wt x-axis, mpg y-axis
render_graph <- function() {
plotly::plot_ly(
mtcars,
x = ~ wt,
y = ~ mpg,
selected = list(marker = list(color = "red")),
hoverinfo = "text",
text = rownames(mtcars),
type = "scatter",
mode = "markers",
source = "graph"
) %>%
plotly::layout(dragmode = "select",
clickmode = "event+select")
}
ui <- fluidPage(fluidRow(
actionButton("action", "Print Selected"),
plotly::plotlyOutput("graph"),
DT::DTOutput("table")
))
server <- function(input, output, session) {
output$table <- DT::renderDT({
mtcars
})
output$graph <- plotly::renderPlotly(render_graph())
plot_proxy <- plotly::plotlyProxy("graph")
table_proxy <- DT::dataTableProxy("table")
observeEvent(input$action, {
selected <-
isolate(plotly::event_data("plotly_selected", source = "graph"))
print(selected)
})
selected_data <- reactive({
selected <-
plotly::event_data("plotly_selected", source = "graph")
selected <- selected$pointNumber + 1
selected
})
observe({
table_proxy %>% DT::selectRows(selected_data())
})
# update the plot based on table
observeEvent(input$table_cell_clicked, {
selected_rows <- input$table_rows_selected - 1
selected_rows <- t(matrix(selected_rows))
plotly::plotlyProxyInvoke(
plotly::plotlyProxy("graph", session),
"restyle",
list(selectedpoints = selected_rows), # arg needs a row-major matrix
0 # this number represents the plot trace. No arg updates all traces
)
})
}
shinyApp(ui, server)
- 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
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.
Issue khác của plotly/plotly.R
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
-
Data gets dropped in add_trace and consequently points have the wrong color if NA is present Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
-
save_image Error Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
Tất cả issue của plotly/plotly.R
Issue tương tự
-
documentation pkg infrastructure
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
epiverse-trace/epiparameter#511 ·
-
Stray pipe in eventRemarks Đang mởfunction:write_dwc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Urgent request: Due to vulnerabilities move to API version 12.6.1 (12.6.2 eventually) or 13.1.1 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
jbkunst/highcharter#849 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
r-lib/pkgdepends#485 · 3 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100