Learn R Programming

echarts4r (version 0.2.0)

e_map: Choropleth

Description

Draw maps.

Usage

e_map(e, serie, map = "world", name = NULL, rm_x = TRUE,
  rm_y = TRUE, ...)

e_map_(e, serie = NULL, map = "world", name = NULL, rm_x = TRUE, rm_y = TRUE, ...)

e_map_3d(e, serie, map = "world", name = NULL, coord_system = NULL, rm_x = TRUE, rm_y = TRUE, ...)

e_map_3d_(e, serie = NULL, map = "world", name = NULL, coord_system = NULL, rm_x = TRUE, rm_y = TRUE, ...)

e_map_3d_custom(e, id, value, height, map = NULL, name = NULL, rm_x = TRUE, rm_y = TRUE, ...)

Arguments

e

An echarts4r object as returned by e_charts.

serie

Values to plot.

map

Map type.

name

name of the serie.

rm_x, rm_y

Whether to remove x and y axis, defaults to TRUE.

...

Any other option to pass, check See Also section.

coord_system

Coordinate system to use, one of cartesian3D, geo3D, globe.

id, value, height

Columns corresponding to registered map.

See Also

e_country_names, https://ecomfe.github.io/echarts-doc/public/en/option.html#series-map, http://echarts.baidu.com/option-gl.html#series-map3D

Examples

Run this code
# NOT RUN {
choropleth <- data.frame(
  countries = c("France", "Brazil", "China", "Russia", "Canada", "India", "United States",
                "Argentina", "Australia"),
  values = round(runif(9, 10, 25))
)

choropleth %>% 
  e_charts(countries) %>% 
  e_map(values) %>% 
  e_visual_map(min = 10, max = 25)

choropleth %>% 
  e_charts(countries) %>% 
  e_map_3d(values, shading = "lambert") %>% 
  e_visual_map(min = 10, max = 30)
  
buildings <- jsonlite::read_json(
  paste0(
    "https://ecomfe.github.io/echarts-examples/",
    "public/data-gl/asset/data/buildings.json"
  )
)

heights <- purrr::map(buildings$features, "properties") %>% 
  purrr::map("height") %>% 
  unlist()
  
names <- purrr::map(buildings$features, "properties") %>% 
  purrr::map("name") %>% 
  unlist()
  
data <- dplyr::tibble(
  name = names,
  value = round(runif(length(names), 0, 1), 6),
  height = heights / 10
)

data %>% 
  e_charts() %>% 
  e_map_register("buildings", buildings) %>%
  e_map_3d_custom(name, value, height) %>% 
  e_visual_map(
    show = FALSE,
    min = 0.4,
    max = 1
  ) 
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab