Home > front end >  hc_yaxis_multiple for add_series_list
hc_yaxis_multiple for add_series_list

Time:03-15

i want to have multiple y axis in highchart, but for any reason the second axis only display the name but not values, below here is an example,

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)

Thank you

CodePudding user response:

You have to specify which of the series you want to display on the primary y-axis by setting the yAxis argument for one (and only for one) series:

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)

  • Related