plotly / plotly/plotly.R

Key variable returned as length 1 character from event_data('plotly_click')

Đang mở
#1,708 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug
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ả

Not sure if this is a bug or not, but I'm using plotly within a Shiny app. I'm using a geom_tile() heatmap type of graph and the user should be able to click a box which then triggers a follow-up database query. I followed the solution here: https://community.plot.ly/t/how-to-return-the-same-event-data-information-for-selected-points-even-after-modifying-the-data/5847/2

However, this doesn't seem to work for a geom_tile() click. I create a key variable by pasting the label and month of the clicked box together. The key is always returned as a length 1 character instead of returning the full string. Full reprex below:

library(plotly)
library(shiny)

mtcars$key <- row.names(mtcars)
mtcars$col <- "black"
mtcars$name <- row.names(mtcars)

ui <- fluidPage(
  plotlyOutput("plot")
)

server <- function(input, output, session) {
  output$plot <- renderPlotly({
    p <- ggplot(mtcars, aes(x = gear, y = name, key = key)) + 
      geom_tile(aes(fill = mpg, key = key))
    ggplotly(p) 
  })
  
  observeEvent(event_data("plotly_click"), {
    click_data <- event_data("plotly_click")
    print(click_data)
   
  })
}
shinyApp(ui, server)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với reprex R/Shiny được cung cấp, tập trung vào geom_tile() và event_data("plotly_click") trong observer plotly_click. Theo dõi cách biến key được truyền cho các lần nhấp vào tile và xác minh kết quả bằng cách đối chiếu với chuỗi tên hàng đầy đủ được mong đợi, thay vì một giá trị character có độ dài một.

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
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.