plotly / plotly/plotly.R

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

Ouverte
#2,110 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
R
Étoiles
2.7k
Forks
641
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par exécuter le MWE fourni avec plot_mapbox(), add_sf(), highlight_key() et highlight(), puis comparez son comportement au survol avec celui de plot_ly(). Étudiez le chemin plot_mapbox et l’interaction entre la cible du survol et la mise en évidence. Le travail est considéré comme terminé lorsque le survol identifie systématiquement la région située sous le pointeur et que la mise en évidence réagit correctement pour la carte présentée.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
r
Domaine
data-visualization
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.