Reputation: 563
The plot below makes a stacked column chart in highcharter. I attempted to make this a grouped column chart, but my addition of the stack field fails to achieve the desired result.
data = data.frame(player = rep(c('Edwin', 'Ahmad', 'Sonia', 'Jessica'), 2),
games = c(10, 20, 15, 40, 12, 57, 18, 49),
win_rate = c(.5, .2, .8, .4, .1, .7, .3, .43),
week = rep(c(1,2), 4))
highcharter::highchart() %>%
highcharter::hc_xAxis(categories = data$player) %>%
highcharter::hc_plotOptions(column = list(stacking = 'normal')) %>%
highcharter::hc_add_series(data = data %>% dplyr::filter(week == 1), type = 'column', highcharter::hcaes(x = player, y = win_rate, stack = week),
dataLabels = list(enabled = TRUE, format='{point.games}')) %>%
highcharter::hc_add_series(data = data %>% dplyr::filter(week == 2), type = 'column', highcharter::hcaes(x = player, y = win_rate, stack = week),
dataLabels = list(enabled = TRUE, format='{point.games}'))
Upvotes: 1
Views: 872
Reputation: 2157
Does this resemble to what you want?
highchart() %>%
hc_xAxis(categories = data$player) %>%
hc_add_series(data = data %>% filter(week == 1), type = 'bar', hcaes(x = player, y = win_rate, group = week),
dataLabels = list(enabled = TRUE, format='{point.games}')) %>%
hc_add_series(data = data %>% filter(week == 2), type = 'bar', hcaes(x = player, y = win_rate, group = week),
dataLabels = list(enabled = TRUE, format='{point.games}'))
Upvotes: 3