仅显示 Highcharter 中的组
Display only groups in Highcharter
我正在使用类似于以下代码的代码来分组显示条形图:
library(purrr) # map function to make grouped categories argument
library(dplyr) # for select function
data(mpg, package = "ggplot2")
mpgg <- mpg %>%
filter(class %in% c("suv", "compact", "midsize")) %>%
group_by(class, manufacturer) %>%
summarize(count = n())
categories_grouped <- mpgg %>%
group_by(name = class) %>%
do(categories = .$manufacturer) %>%
list_parse()
highchart() %>%
hc_xAxis(categories = categories_grouped) %>%
hc_add_series(data = mpgg, type = "bar", hcaes(y = count, color = manufacturer),
showInLegend = FALSE)
我得到以下图表:
Highchart Group Categories Wise
由于错位,我只想显示没有类别的组。我尝试了几种解决方案,但总是存在对齐问题。
有什么解决办法吗?
如果您不需要两组类别,您可以只定义没有分组的标准类别-categories.js 模块,就像这个 JS 示例:jsfiddle.net/BlackLabel/29kgtp3u
我正在使用类似于以下代码的代码来分组显示条形图:
library(purrr) # map function to make grouped categories argument
library(dplyr) # for select function
data(mpg, package = "ggplot2")
mpgg <- mpg %>%
filter(class %in% c("suv", "compact", "midsize")) %>%
group_by(class, manufacturer) %>%
summarize(count = n())
categories_grouped <- mpgg %>%
group_by(name = class) %>%
do(categories = .$manufacturer) %>%
list_parse()
highchart() %>%
hc_xAxis(categories = categories_grouped) %>%
hc_add_series(data = mpgg, type = "bar", hcaes(y = count, color = manufacturer),
showInLegend = FALSE)
我得到以下图表:
Highchart Group Categories Wise
由于错位,我只想显示没有类别的组。我尝试了几种解决方案,但总是存在对齐问题。
有什么解决办法吗?
如果您不需要两组类别,您可以只定义没有分组的标准类别-categories.js 模块,就像这个 JS 示例:jsfiddle.net/BlackLabel/29kgtp3u