This looks as expected:
df <- structure(list(surveillance_diag = c("Meningitis", "Sepsis"),
y = c(1239L, 7850L), color = c("#1f78b4", "#e31a1c"),
freq = c(14, 86)), row.names = c(NA, -2L), class = c("tbl_df", "tbl", "data.frame"))
library(highcharter)
library(magrittr)
highchart() %>%
hc_yAxis(title = "") %>%
hc_xAxis(categories = df$surveillance_diag) %>%
hc_add_series(data = df, type = "bar", hcaes(x = surveillance_diag, y = y, color = color))
But the same code with a data frame of only one row/category will cut the category label.
df <- df[1, ]
highchart() %>%
hc_yAxis(title = "") %>%
hc_xAxis(categories = df$surveillance_diag) %>%
hc_add_series(data = df, type = "bar", hcaes(x = surveillance_diag, y = y, color = color))
How can I ensure that the label is properly displayed regardless of the number of categories?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.