Search code examples
rr-highcharter

Two pies in the same graph - Highcharter


I am trying to reproduce the following example of two pies in the same highchart graph with no success. An example code below. Does any one knows how to create two charts in the same chart in highcharter?

df = tibble(name = c("a","b","c"),
        a1 = c(10,12,11),
        a2 = c(22,23,22))
highchart() %>%
hc_chart(renderTo = "container", type = "pie") %>%
hc_add_series(df, hcaes(name, a1), size = 100, center = c(30,10)) %>%
hc_add_series(df, hcaes(name, a2), size = 100, center = c(10,30)) 

Solution

  • A possible solution

    highcharter::hw_grid(
      hchart(df, type = "pie", mapping = hcaes(name, a1))
      ,
      hchart(df, type = "pie", mapping = hcaes(name, a2))
    ) %>% htmltools::browsable()
    

    enter image description here