Title: | Mapping China and Its Provinces |
---|---|
Description: | 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. |
Authors: | Zhenxing Cheng [aut, cre] |
Maintainer: | Zhenxing Cheng <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2025-02-11 04:42:45 UTC |
Source: | https://github.com/cran/hchinamap |
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.
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")
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.
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") }
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") }
Output and render functions for using hchinamap within Shiny applications and interactive Rmd documents.
hchinamapOutput(outputId, width = "100%", height = "400px") renderHchinamap(expr, env = parent.frame(), quoted = FALSE)
hchinamapOutput(outputId, width = "100%", height = "400px") renderHchinamap(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width , height
|
Must be a valid CSS unit (like |
expr |
An expression that generates a hchinamap |
env |
The environment in which to evaluate |
quoted |
Is |