I want to plot a multiple stacked bar chart, but I don\'t know how to combine the r code.
Closing Date Non Current Assets Current Assets Non Current Liabil
You can specify which bars belong in which groups by adding stack
to each series, like this:
library(highcharter)
bs.table = data.frame(
Closing.Date = paste(2013:2017, 12, sep = "/"),
Non.Current.Assets = c(13637344, 14075507, 14578093, 10911628, 10680998),
Current.Assets = c(13078654, 12772388, 14226181, 10205708, 10950779),
Non.Current.Liabilities = c(9376243, 8895126, 9715914, 9810157, 13493110),
Current.Liabilities = c(5075985, 4963856, 5992229, 8859263, 4094183)
)
highchart() %>%
hc_chart(type = "column") %>%
hc_plotOptions(column = list(stacking = "normal")) %>%
hc_xAxis(categories = bs.table$Closing.Date) %>%
hc_add_series(name="Non Current Assets",
data = bs.table$Non.Current.Assets,
stack = "Assets") %>%
hc_add_series(name="Current Assets",
data = bs.table$Current.Assets,
stack = "Assets") %>%
hc_add_series(name="Non Current Liabilities",
data = bs.table$Non.Current.Liabilities,
stack = "Liabilities") %>%
hc_add_series(name="Current Liabilities",
data = bs.table$Current.Liabilities,
stack = "Liabilities") %>%
hc_add_theme(hc_theme_ft())
(To group by current vs. non-current instead of assets vs. liabilities, just rename stack
in each series appropriately.)