我想创建一个柱形图,其中只有最后一列具有模式(在下面的示例中为2020年),其余列具有实心填充。我知道可以用hc_add_dependency("modules/pattern-fill.js")
添加的模式填充模块,但我很难让它为我的图表工作。事实上,我甚至不能将默认(纯色)颜色更改为自定义颜色。我真的很感激你的帮助!非常感谢!
下面是一个最小的例子:
library(tidyverse)
library(highcharter)
df <- data.frame(cbind(seq(2001, 2020, by=1),
sample(1:15, size=20, replace=T),
sample(1:15, size=20, replace=T)))
colnames(df) <- c("year", "newA", "newB")
highchart() %>%
hc_chart(type = "column") %>%
hc_add_series(
name = "New A",
data = df$newA,
stack = "new",
showInLegend = F) %>%
hc_add_series(
name = "New B",
data = df$newB,
stack = "new",
showInLegend = F) %>%
hc_plotOptions(column = list(stacking = "normal")) %>%
hc_xAxis(categories = df$year, title = list(text = ""))
字符串
1条答案
按热度按时间cyej8jka1#
在此示例中,使用单个数据系列创建柱形图。只有最后一列(“第3天”)用模式填充,如hc_add_series()函数中所指定的。对于这个列,我们提供了一个包含值('y')和颜色规范的列表,而不是只提供一个值:
字符串