hc_add_series_map: Add a map series

Description Usage Arguments Details Examples

View source: R/highmaps.R

Description

Add a map series

Usage

1
hc_add_series_map(hc, map, df, value, joinBy, ...)

Arguments

hc

A highchart htmlwidget object.

map

A list object loaded from a geojson file.

df

A data.frame object with data to chart. Code region and value are required.

value

A string value with the name of the variable to chart.

joinBy

What property to join the map and df

...

Additional shared arguments for the data series (https://api.highcharts.com/highcharts/series).

Details

This function force the highchart object to be map type.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
library("dplyr")

data("USArrests", package = "datasets")
data("usgeojson")

USArrests <- mutate(USArrests, state = rownames(USArrests))

highchart() %>%
  hc_title(text = "Violent Crime Rates by US State") %>%
  hc_subtitle(text = "Source: USArrests data") %>%
  hc_add_series_map(usgeojson, USArrests,
    name = "Murder arrests (per 100,000)",
    value = "Murder", joinBy = c("woename", "state"),
    dataLabels = list(
      enabled = TRUE,
      format = "{point.properties.postalcode}"
    )
  ) %>%
  hc_colorAxis(stops = color_stops()) %>%
  hc_legend(valueDecimals = 0, valueSuffix = "%") %>%
  hc_mapNavigation(enabled = TRUE)
## Not run: 

data(worldgeojson, package = "highcharter")
data("GNI2014", package = "treemap")

highchart(type = "map") %>%
  hc_add_series_map(map = worldgeojson, df = GNI2014, value = "GNI", joinBy = "iso3") %>%
  hc_colorAxis(stops = color_stops()) %>%
  hc_tooltip(
    useHTML = TRUE, headerFormat = "",
    pointFormat = "this is {point.name} and have {point.population} people with gni of {point.GNI}"
  )

## End(Not run)

highcharter documentation built on Jan. 3, 2022, 5:08 p.m.