score:0

Accepted answer

i needed to rebuild a little bit your code. you need to use chart.addsingleseriesasdrilldown() method in chart.events.drilldown event. this is your whole code:

hc <- highchart() %>%
  hc_chart(
    type = "column",
    events = list(
      drilldown = js(
        "function(e) {
          if (!e.seriesoptions) {
            var chart = this;
            chart.addsingleseriesasdrilldown(e.point, {
              color: highcharts.getoptions().colors[0],
              name: 'completed',
              data: [
                ['job a1', 40],
                ['job b1', 35]
              ]
            });
            chart.addsingleseriesasdrilldown(e.point, {
              color: highcharts.getoptions().colors[1],
              name: 'no progress',
              data: [
                ['job a1', 60],
                ['job b1', 65]
              ]
            });

            chart.applydrilldown();
          }
        }"
      )
    )
  ) %>%
  hc_title(text = "job ratio") %>%
  hc_xaxis(type = "category") %>%
  hc_plotoptions(series = list(stacking = "normal")) %>%
  hc_yaxis(max = 100) %>%
  hc_add_series(
    name = "completed", 
    data = list(
      list(name = "job a", y = 40, drilldown = t), 
      list(name = "job b", y = 35, drilldown = t)
    )
  ) %>%
  hc_add_series(
    name = "no progress",
    data = list(
      list(name = "job a", y = 60), 
      list(name = "job b", y = 65)
    )
  ) %>%
  hc_drilldown(
    series = list()
  )
hc

and here you can take a look at the pure js implementation: https://jsfiddle.net/blacklabel/m089w4yh

api: https://api.highcharts.com/highcharts/chart.events.drilldown


Related Query

More Query from same tag