This PR adds minimal code to support stacked bar chart with a grouped_tt class (grouped tidytable).
Currently, echarts4r handles grouped tibbles nicely (class grouped_df). The code below will make a stacked barplot..
x <- c("a", "a", "b", "b")
g <- c("g1", "g2", "g1", "g2")
y <- c(1, 1, 1, 1)
d <- data.frame(x, g, y)
grp_d <- d |> dplyr::group_by(g)
grp_d |>
e_chart(x) |>
e_bar(y, stack = "g")
However, if one does not user dplyr but tidytable, the resulting grouped data frame is not of class grouped_df, but grouped_tt. The code results with this
x <- c("a", "a", "b", "b")
g <- c("g1", "g2", "g1", "g2")
y <- c(1, 1, 1, 1)
d <- data.frame(x, g, y)
grp_d <- d |> tidytable::group_by(g)
grp_d |>
e_chart(x) |>
e_bar(y, stack = "g")
With the this PR, I added an else if condition in map_grps_ to use base::split to split the grouped tidytable (instead of dplyr::group_split), such that grouped tidytables also produce stacked barcharts.
I have not tested it thoroughly. I don't know all the features that depend on map_grps_, but the proposed addition should not affect any dplyr-dependent code. Happy to work on this more if needed.
This PR adds minimal code to support stacked bar chart with a
grouped_tt
class (groupedtidytable
).Currently,
echarts4r
handles grouped tibbles nicely (classgrouped_df
). The code below will make a stacked barplot..However, if one does not user
dplyr
buttidytable
, the resulting grouped data frame is not of classgrouped_df
, butgrouped_tt
. The code results with thisWith the this PR, I added an
else if
condition inmap_grps_
to usebase::split
to split the grouped tidytable (instead ofdplyr::group_split
), such that grouped tidytables also produce stacked barcharts.I have not tested it thoroughly. I don't know all the features that depend on
map_grps_
, but the proposed addition should not affect any dplyr-dependent code. Happy to work on this more if needed.Thanks!