echarts4r icon indicating copy to clipboard operation
echarts4r copied to clipboard

Issue with bar stacking in version 0.4.4

Open PaulC91 opened this issue 1 year ago • 3 comments

Hi John,

I seem to have found a bar stack issue after updating to version 0.4.4 (was previously using 0.4.0 and did not have this problem with the exact same example below).

Now I am getting gaps between some of the bars that do not represent any data (there's no missing data in this example), and some bars actually overlap each other rather than starting at the end of the previous bar.

Any idea what's happening here?

Thanks.

 library(dplyr)
 library(echarts4r)
 library(outbreaks) # install.packages('outbreaks')
 
 df_linelist <- tibble(outbreaks::ebola_sim_clean$linelist)
 
df_linelist %>%
   mutate(week = lubridate::floor_date(date_of_hospitalisation, "week", 1)) %>% 
   count(week, gender) %>%
   group_by(gender) %>%
   e_charts(week) %>%
   e_bar(n, stack = "group") %>% 
   e_axis_labels(x = "week", y = "n") %>%
   e_tooltip(trigger = "axis") %>%
   e_x_axis(type = "time")

Screenshot 2022-09-06 at 16 25 37

PaulC91 avatar Sep 06 '22 14:09 PaulC91

ECharts documentation says: time and category axis are not supported (in stack).
But if you change the last line to e_x_axis(type = "category") - it works fine. Enjoy the confusion!

helgasoft avatar Sep 06 '22 20:09 helgasoft

Thanks @helgasoft. I did see that in the ECharts docs actually but thought it may be outdated as I can see they have examples of category axis stacked bars on their examples page, and the time axis stack was working fine previously. Very confusing!

PaulC91 avatar Sep 07 '22 08:09 PaulC91

You are right - echarts4R v.0.4.1 is using ECharts v.5.1.1 and your code works with xAxis type time. Now with ECharts v.5.3.2 (and even 5.3.3) - it no longer does.

helgasoft avatar Sep 07 '22 16:09 helgasoft