Search code examples
rhighchartsr-highcharter

Highcharts/highcharteR ignores point color when plotting 50+ series


I've run into the problem where Highcharts/highcharteR seems to ignore individual point colours when plotting a certain number of series.

Reproducible example:

library(highcharter)

ll <- list()
for (i in 1:50) {
  ll[[i]] <- list(
              name = i,
              data = list_parse(
                        data.frame("x" = rep(i, 3),
                                   "y" = sample(1:10, 3, replace=TRUE),
                                   "z" = sample(1:5, 3, replace=TRUE),
                                   "color" = sample(c("green","red","grey"), 3))
                     )
              )
}
highchart() %>%
    hc_chart(type = "bubble") %>%
    hc_add_series_list(ll)

When running the above, you'll see random colours (assigned per series) instead of the explicitly specified green/red/grey colours. Changing the final line to hc_add_series_list( ll[1:49] ) shows the correct, specified colours. I thought it was a problem with the final list item, but changing the final line to hc_add_series_list( ll[2:50] ) also gives the correct result.

Generating a list with only 49 items (i.e., changing for (i in 1:50) to for (i in 1:49) does not have this problem (while generating a list with 51 items does). It seems that plotting 50 or more series is some sort of cut-off. Is this a highcharts/JS limitation?


Solution

  • Turns out it is an issue with highcharteR's boost, which is enabled by default. Not sure what it does but thanks to this GitHub comment, I found that adding %>% hc_boost(enabled = FALSE) solves the problem.

    PS. Thanks to @raf18seb for testing whether this problem persists in pure JS (it doesn't).