library(dplyr)
df <- mtcars |> group_by(cyl,gear) |> summarise(yy= round(mean(mpg),2)) |>
mutate(low= round(yy-cyl*runif(1),2), high= round(yy+cyl*runif(1),2))
ec.init(df, load= 'custom', ctype= 'bar', tooltip= list(show=TRUE),
xAxis= list(type='category')) |>
ecr.ebars(encode= list(y=c(3,4,5), x=2))
# ----- riErrBarSimple ------
df <- mtcars |> mutate(x=1:nrow(mtcars),hi=hp-drat*3, lo=hp+wt*3) |> select(x,hp,hi,lo)
ec.init(df, load= 'custom', legend= list(show= TRUE)) |>
ec.upd({ series <- append(series, list(
list(type= 'custom', name= 'error',
data= ec.data(df |> select(x,hi,lo)),
renderItem= htmlwidgets::JS('riErrBarSimple')
)))
})
Run the code above in your browser using DataLab