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)

Lines

Use e_lines (not e_line)

flights <- read.csv(
  paste0("https://raw.githubusercontent.com/plotly/datasets/",
         "master/2011_february_aa_flight_paths.csv")
)

flights |> 
  e_charts() |> 
  e_geo() |> 
  e_lines(
    start_lon, 
    start_lat, 
    end_lon, 
    end_lat,
    name = "flights",
    lineStyle = list(normal = list(curveness = 0.3))
   )

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)