score:1

Accepted answer

You can add categories to your hc_xAxis to make an order like this:

library(highcharter) 

dta |> 
  hchart(type = "column", hcaes(x = "event", y = "n", group = "sociodemographic_var")) |> 
  hc_yAxis(title = list(text = "%"), max = 115, endOnTick = FALSE, stackLabels = list(enabled = TRUE)) |> 
  hc_xAxis(title = "", categories = levels(dta$event)) |> 
  hc_plotOptions(series = list(stacking = "percent"))

Output:

enter image description here


Related Articles