JohnCoene / echarts4r

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

Is it possible to plot multiple gauge plots by implementing e_gauge with e_facet? #524

Closed Robinmoon26 closed 1 year ago

Robinmoon26 commented 1 year ago

I was trying to plot multiple gauge plots from a dataframe at once as below:

df<-data.frame("group"=c("A","B","C"), "value"=c(57, 23, 65))

df|> e_charts( |> e_gauge(df$value, df$group ) |> e_facet(rows = 1, cols=3)

However, the figure showed as below, instead of having 3 gauge plots in a row: gauge_error

I would like to know how to plot it in a right way. Thanks very much for your time.

rdatasculptor commented 1 year ago

@Robinmoon26 I must admit I coudn't make it work with e_facet either.

Another approach (and maybe that will solve it for now) is using the function combineWidgets() of the manipulateWidget package:

library(echarts4r)
library(manipulateWidget)

df<-data.frame(group=c("A","B","C"), 
               value=c(57, 23, 65))

df1 <-
  e_charts() |> 
  e_gauge(df$value[1], df$group[1])

df2 <-
  e_charts() |> 
  e_gauge(df$value[2], df$group[2])

df3 <-
  e_charts() |> 
  e_gauge(df$value[3], df$group[3])

combineWidgets(df1, df2, df3, nrow = 1)

CombineWidgets has saved my day many times :)