Chain commands after ec.init to add or update chart items
Details
ec.upd makes changes to a chart already set by ec.init.
It should be always piped(chained) after ec.init.
All numerical indexes for series,visualMap,etc. are JS-counted starting at 0.
Examples
library(dplyr)
df <- data.frame(x= 1:30, y= runif(30, 5, 10), cat= sample(LETTERS[1:3],size=30,replace=TRUE)) |>
mutate(lwr= y-runif(30, 1, 3), upr= y+runif(30, 2, 4))
band.df <- df |> group_by(cat) |> group_split()
df |> group_by(cat) |>
ec.init(load='custom', ctype='line',
xAxis=list(data=c(0,unique(df$x)), boundaryGap=FALSE) ) |>
ec.upd({
for(ii in 1:length(band.df)) # add bands to their respective groups
series <- append(series,
ecr.band(band.df[[ii]], 'lwr', 'upr', type='stack', smooth=FALSE,
name= unique(band.df[[ii]]$cat), areaStyle= list(color=c('blue','green','yellow')[ii])) )
})
#> Error in eval(substitute(expr), e): object 'band.df' not found