Data & policies & politics

Hi John! Here you can find the original code and data

Session info

R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.14.2

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] echarts4r.maps_0.0.2   echarts4r_0.2.2        echarts4r.suite_0.0.1  echarts4r.assets_0.0.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0       rstudioapi_0.9.0 magrittr_1.5     tidyselect_0.2.5 xtable_1.8-3     R6_2.4.0         rlang_0.3.1     
 [8] dplyr_0.8.0.1    tools_3.5.1      cli_1.0.1        htmltools_0.3.6  yaml_2.2.0       assertthat_0.2.0 digest_0.6.18   
[15] tibble_2.0.1     crayon_1.3.4     shiny_1.2.0      purrr_0.3.0      later_0.8.0      htmlwidgets_1.3  promises_1.0.1  
[22] glue_1.3.0       mime_0.6         compiler_3.5.1   pillar_1.3.1     jsonlite_1.6     httpuv_1.4.5.1   pkgconfig_2.0.2

I made four trials so you can see the issues in each one

Base code for all 4 maps

# about: attempts to display tooltip correctly in echarts4r 
library(tidyverse)
library(echarts4r.assets)
library(echarts4r.suite)
library(echarts4r.maps)

# mapboox key
key <- "........"

# data
df <- read.csv("data.csv")

# setting emphasis and transparency of scatter points
transparency <- list(opacity = 0.6)
emphasis <- list(itemStyle = list(color = "#add8e6"))

# base map
p <- df %>% 
  e_charts(long) %>% 
  e_mapbox(
    token = key,
    style = "mapbox://styles/mapbox/dark-v9",
    center = c(-64.0239289,-16.35223),
    zoom = 5,
    pitch = 30
  )

First attempt: value argument used in e_visual_map and e_scatter_3d

p %>% 
  e_scatter_3d(lat, value, coord_system = "mapbox", bind = place, 
               itemStyle = transparency, emphasis = emphasis) %>% 
  e_visual_map(value, min = 0, max = 100, bottom = 300) %>% 
  e_tooltip() %>% 
  htmlwidgets::saveWidget(., "echarts.html")

First attempt result:

expand

  • Colour range does not work
  • Colour emphasis only available for high values
  • Tooltip does not work regularly

Second  attempt: value argument omitted in e_visual_map and e_scatter_3d

p %>% 
  e_scatter_3d(lat, value, coord_system = "mapbox", bind = place, 
               itemStyle = transparency, emphasis = emphasis) %>% 
  e_visual_map(min = 0, max = 100, bottom = 300) %>% 
  e_tooltip() %>% 
  htmlwidgets::saveWidget(., "echarts_1.html")

Second attempt result:

expand

  • Colour range  and colour emphasis work normally
  • Tooltip does not work regularly, it comes and goes and pops up where there are no dots

Third attempt: value argument used  in e_visual_map and e_bar_3d instead of e_scatter_3d

p %>% 
  e_bar_3d(lat, value, coord_system = "mapbox", bind = place, 
               itemStyle = transparency, emphasis = emphasis) %>% 
  e_visual_map(value, min = 0, max = 100, bottom = 300) %>% 
  e_tooltip() %>% 
  htmlwidgets::saveWidget(., "echarts_3.html")

Third attempt result:

expand

  • Tooltip works perfectly. However colour range slider does not . It only works when pointing the highest part in the bar.
  • Additionaly, when zooming  in on squares they become big and do not let see the map behind it visible

Fourth  attempt: value argument ommited in e_visual_map and e_scatter_3d

p %>% 
  e_bar_3d(lat, value, coord_system = "mapbox", bind = place, 
           itemStyle = transparency, emphasis = emphasis) %>% 
  e_visual_map(min = 0, max = 100, bottom = 300) %>% 
  e_tooltip() %>% 
  htmlwidgets::saveWidget(., "echarts_4.html")

Fourth attempt result:

expand

Everything works perfectly except when zooming in (same as the previous one)