0

I really like echarts4r and I would like to be able to use it for building a 2D choropleth map. My issue is that it looks like echarts4r can only do this with a predefined set of regions/areas. In particular, I would like to map the UK split by county, and also London split by borough, and neither of these are in the predefined set used by echarts4r. (The UK is split into England, Wales, Northern Ireland, and Scotland but not into counties.)

For reference, the function I'm looking at is echarts4r::e_map and I'm also seeing the existing predefined area data sets in the Github page for echarts4r.maps.

It's also worth mentioning that the geometry data I have for the regions/areas is a column of class sfc containing simple features data. I'm currently using this with ggplot2::geom_sf.

Thanks!

1 Answers1

0

Found out that I just needed to make sure I have the map data in a geojson format and then implement something along the lines of the bottom section on this page: https://echarts4r.john-coene.com/articles/map.html#geojson-support-1

json <- jsonlite::read_json("https://raw.githubusercontent.com/shawnbot/topogram/master/data/us-states.geojson")

USArrests |>
  tibble::rownames_to_column("states") |> 
  e_charts(states) |>
  e_map_register("USA", json) |>
  e_map(Murder, map = "USA") |> 
  e_visual_map(Murder)