0

I would like to create a graph with the package echarts4r, with the following data:

group_size <- 20
n_groups <- 13
df <- data.frame("day" = rep(1:group_size, times=n_groups), 
                 "temperature" = runif(group_size * n_groups, 10, 40),
                 "location" = rep(LETTERS[1:n_groups], each=group_size)) %>% 
  mutate("other" = if_else((day %% 2) == 0, "A1", "A2"))
  

the graph I would like (with ggplot) :

   df %>% 
      ggplot()+ geom_line(aes(x= day, y = temperature, color = location))+
      facet_wrap(~other) 

How to reproduce it with echarts4r (how to specify a color for each location for example )

I tried

  df |> 
  group_by(other) |> 
  e_charts(day) |> 
  e_line(temperature) |> 
  e_facet(rows = 2, legend_pos = "top", legend_space = 12) 
stefan
  • 90,330
  • 6
  • 25
  • 51
Felipe
  • 719
  • 8
  • 20
  • 1
    Does this help: https://stackoverflow.com/questions/73718259/e-facet-using-grouped-data-in-echarts4r-question – nrennie Jun 13 '23 at 16:59
  • Consider using `e_add_nested()`, take a look here for inspiration: https://echarts4r.john-coene.com/reference/nesting.html – rdatasculptor Jul 15 '23 at 16:46

0 Answers0