hc_yaxis_multiple 对于 add_series_list

hc_yaxis_multiple for add_series_list

我想在 highchart 中有多个 y 轴,但是出于某种原因第二个轴只显示名称而不显示值,下面是一个示例,

ds <- lapply(seq(1), function(x) {
  list(data = cumsum(rnorm(100, 2, 5)), name = "1")
})

da <- lapply(seq(1), function(x) {
  list(data = cumsum(rnorm(100, 2, 5)), name = "2")
})

highchart() %>%
  hc_plotOptions(series = list(marker = list(enabled = FALSE))) %>%
  hc_yAxis_multiples(list(title = list(text = "Retention"), opposite = FALSE),
                     list(showLastLabel = TRUE, opposite = TRUE, title = list(text = "Limit")))%>%
  hc_add_series_list(ds)%>%
  hc_add_series_list(da)

谢谢

您必须通过为一个(且仅一个)系列设置 yAxis 参数来指定要在主要 y-axis 上显示哪个系列:

set.seed(123)

ds <- lapply(seq(1), function(x) {
  list(data = cumsum(rnorm(100, 2, 5)), name = "1")
})

da <- lapply(seq(1), function(x) {
  list(data = cumsum(rnorm(100, 2, 5)), name = "2", yAxis = 1)
})

library(highcharter)

highchart() %>%
  hc_plotOptions(series = list(marker = list(enabled = FALSE))) %>%
  hc_yAxis_multiples(list(title = list(text = "Retention"), opposite = FALSE),
                     list(showLastLabel = TRUE, opposite = TRUE, title = list(text = "Limit")))%>%
  hc_add_series_list(ds)%>%
  hc_add_series_list(da)