plotly / plotly/plotly.R

plot_mapbox() causes precision and slowness issues with hover and highlight features

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

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ả

Hi folks, choropleth maps using plotly + simple features + mapbox as base map is the perfect combination in my opinion, it is really beautiful and functional.

However, I have not been able to use it because, when plot_mapbox() is used as opposed to plot_ly(), hover gets very imprecise and the highlight very slow.

Consider this MWE:

devtools::install_github("ipeaGIT/geobr", subdir = "r-package")
library(geobr)
library(sf)
library(plotly)

mapbox_token <- "your mapbox token"
Sys.setenv('MAPBOX_TOKEN'=mapbox_token)

data_sf <- geobr::read_region(year=2010) %>%
    sf::st_cast("MULTIPOLYGON")

plot_mapbox() %>% 
  add_sf(
    data = data_sf %>% highlight_key(~name_region),
    split = ~name_region, showlegend = FALSE, 
    text = ~paste0(name_region,": ",code_region),
    hoverinfo = "text"
  ) %>% 
  highlight(on = "plotly_hover", off = "plotly_doubleclick")

For example, as shown in the picture below, while the mouse is pointing to the blue region, the hover shows the info from the red region.
image

Another example, here the mouse is pointing right in the middle of the blue region but no hover data is shown.
image

And finally, the highlight_key() is a very valuable feature, nonetheless it is too slow and laggy to be effectively used with plot_mapbox(), at least in my machine, do you have different experiences with it?

R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    
system code page: 65001

attached base packages:
[1] stats     graphics  grDevices utils    
[5] datasets  methods   base     

other attached packages:
[1] geobr_1.6.6   sf_1.0-6      plotly_4.10.0
[4] ggplot2_3.3.5

Thank you

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 bằng cách chạy MWE được cung cấp với plot_mapbox(), add_sf(), highlight_key() và highlight(), sau đó so sánh hành vi hover của nó với plot_ly(). Điều tra đường đi của plot_mapbox và sự tương tác giữa mục tiêu hover với việc làm nổi bật. Được xem là hoàn tất khi hover luôn xác định đúng vùng nằm dưới con trỏ và việc làm nổi bật phản hồi nhanh trên bản đồ được minh họa.

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

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.