Description Usage Arguments Note Examples
By binding R functions and the 'Highmaps' <https://www.highcharts.com.cn/products/highmaps> chart library,'hchinamap' package provides a simple way to map China and its provinces. The map of China drawn by this package contains complete Chinese territory, especially the Nine-dotted line, South Tibet, Hong Kong, Macao and Taiwan.
1 2 3 4 5 6 7 8 9 | hchinamap(name, value, region = "China", width = NULL, height = NULL,
elementId = NULL, itermName = "Random data", title = "",
titleAlign = "center", titleSize = "20px", titleColor = "#333333",
subtitle = "", subtitleAlign = "center", subtitleSize = "",
subtitleColor = "#666666", min = 0, minColor = "rgb(255,255,255)",
maxColor = "#006cee", legendLayout = "horizontal",
legendAlign = "center", legendTitle = "",
legendVerticalAlign = "bottom", hoverColor = "#a4edba",
theme = "sunset")
|
name |
Chinese name vector of provinces or prefecture-level cities in China. |
value |
Value vector; |
region |
Region name in English, Such as "China", "Anhui" ...; |
width |
Chart width; |
height |
Chart height; |
elementId |
NULL |
itermName |
Data attributes in tooltip; |
title |
Chart title; |
titleAlign |
The horizontal position of the title, such as "center"; |
titleSize |
The size of the title, such as "20px"; |
titleColor |
The color of the title, such as "#3333"; |
subtitle |
Subtitle of chart; |
subtitleAlign |
The horizontal position of subtitles, such as "center"; |
subtitleSize |
The size of the subtitle, such as "16px"; |
subtitleColor |
The color of the subtitle, such as "#666666"; |
min |
The minimum value of legend, 0 by default. |
minColor |
The color corresponding to the minimum of the legend, such as "white"; |
maxColor |
The color corresponding to the maximum value of the legend, such as "#006cee"; |
legendLayout |
Legend, horizontal or vertical; |
legendAlign |
Horizontal position of legend, center/left/right; |
legendTitle |
The title of the legend; |
legendVerticalAlign |
The vertical position of legends, top/center/bottom; |
hoverColor |
The color of the area when the mouse is hovering. |
theme |
Chart theme, you can choose one from: darkgreen/darkblue/avocado/darkunica/gray/ gridlight/grid/sandsignika/sunset; |
Because the map data of Taiwan have not been collated yet, it is impossible to draw provincial map of Taiwan Province for the time being.
1 2 3 4 5 6 7 8 9 10 11 | library(hchinamap)
library(dplyr)
library(magrittr)
dir <- tempdir()
download.file('https://czxb.github.io/br/chinadf.rda', file.path(dir, 'chinadf.rda'))
load(file.path(dir, 'chinadf.rda'), verbose = TRUE)
china <- chinadf %>%
dplyr::filter(region == "China")
if(interactive()) {
hchinamap(name = china$name, value = china$value, region = "China")
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.