This document describes the maps.
Choropleth
Pass countries as x
argument.
cns <- countrycode::codelist$country.name.en
cns <- data.frame(
country = cns,
value = runif(length(cns), 1, 100)
)
cns |>
e_charts(country) |>
e_map(value) |>
e_visual_map(value)
Countries
The companion package echarts4r.maps comes with 215 maps.
You can install the package with:
install.packages("remotes")
remotes::install_github('JohnCoene/echarts4r.maps')
View the full list of maps with
echarts4r.maps::em_bank()
.
library(echarts4r.maps)
df <- data.frame(
region = c("Rajasthan", "Odisha", "Gujarat"),
value = c(1,2, 3)
)
df |>
e_charts(region) |>
em_map("India") |>
e_map(value, map = "India") |>
e_visual_map(value) |>
e_theme("infographic")
GeoJSON support
Use a custom geojson map; 1) read
the json and register it with e_register_map
.
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)