knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
You see the maps available by running the following:
em_bank()
Otherwise, the full list of maps is vailable here.
There are 215 maps, here are two.
library(echarts4r) library(echarts4r.maps) jp <- e_charts() %>% em_map("Japan") %>% e_map(map = "Japan") ca <- e_charts() %>% em_map("Canada") %>% e_map(map = "Canada") e_arrange(jp, ca, cols = 2, rows = 1)
Use em_map
to add the map, simply pass the name of the country, a valid name as returned by em_bank
, then reference that name in e_map
.
library(echarts4r) library(echarts4r.maps) data(state) state.x77 <- as.data.frame(state.x77) state.x77$state <- row.names(state.x77) state.x77 %>% e_charts(state) %>% em_map("USA") %>% e_map(Population, map = "USA") %>% e_visual_map(Population)
This will also work in 3d with e_map_3d
.
state.x77 %>% e_charts(state) %>% em_map("USA") %>% e_map_3d(Income, map = "USA") %>% e_visual_map(Income)
And e_geo_3d
state.x77 %>% e_color_range(Murder, Color) %>% dplyr::mutate(Frost = sqrt(Frost)) %>% e_charts(state) %>% em_map("USA") %>% e_geo_3d(Frost, Color, type = "USA") %>% e_visual_map(Frost)
library(echarts4r.maps) flights <- read.csv( paste0("https://raw.githubusercontent.com/plotly/datasets/", "master/2011_february_aa_flight_paths.csv") ) flights %>% e_charts() %>% em_map("USA") %>% e_geo("USA") %>% e_lines( start_lon, start_lat, end_lon, end_lat, name = "flights", lineStyle = list(normal = list(curveness = 0.3)) )
library(dplyr) data("cities") cities %>% filter(country == "IN") %>% mutate(val = runif(n(), 1, 3)) %>% e_charts(lon) %>% em_map("India") %>% e_geo(map = "India") %>% e_scatter(lat, val, coord_system = "geo", scale = NULL) %>% e_visual_map(min = 1, max = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.