highcharts 添加系列列表的hc_yaxis_multiple

rn0zuynd  于 2022-11-11  发布在  Highcharts
关注(0)|答案(1)|浏览(129)

我想在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)

谢谢你

7ivaypg9

7ivaypg91#

您必须为一个(且仅为一个)序列设置yAxis参数,以指定要在主y轴上显示的序列:

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)

相关问题