# 常量
ELEMENTS <- names(theme_get())
# 初始化默认主题
ele_config <- yaml::read_yaml("ele_config.yaml")
theme_init <- theme_get()
new_theme <- reactiveValues()
for (ele in names(theme_init)) {
if (is.null(theme_init[[ele]])) {
theme_init[ele] <- list(do.call(ele_config[[ele]], list()))
}
new_theme[[ele]] <- theme_init[[ele]]
}
rm(ele)
# 初始化默认数据
set.seed(2414)
dat_src <- data.frame(
long = rnorm(100),
lat = rnorm(100),
facet_x = sample(c("East", "West"), 100, replace = TRUE),
facet_y = sample(c("Sourth", "North"), 100, replace = TRUE),
shape = sample(c("ShapeX", "ShapeY", "ShapeZ"), 100, replace = TRUE),
color = sample(c("SizeX", "SizeY", "SizeZ"), 100, replace = TRUE)
)
# 初始化默认示例图
default_plot <- reactiveValues(base = ggplot(dat_src, aes(long, lat)))
# 初始化自定义示例图
custom_plot <- reactiveValues(plot = NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.