JohnCoene / echarts4r

🐳 ECharts 5 for R
http://echarts4r.john-coene.com/
Other
593 stars 81 forks source link

Issue with bar stacking in version 0.4.4 #458

Open PaulC91 opened 2 years ago

PaulC91 commented 2 years ago

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

helgasoft commented 2 years ago

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!

PaulC91 commented 2 years ago

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!

helgasoft commented 2 years ago

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.