ecr.band: Area band

ecr.bandR Documentation

Area band

Description

A 'custom' serie with lower and upper boundaries

Usage

ecr.band(df = NULL, lower = NULL, upper = NULL, type = "polygon", ...)

Arguments

df

A data.frame with lower and upper numerical columns and first column with X coordinates.

lower

The column name(string) of band's lower boundary.

upper

The column name(string) of band's upper boundary.

type

Type of rendering

  • 'stack' - by two stacked lines

  • 'polygon' - by drawing a polygon as polyline (default). Warning: cannot be zoomed!

...

More parameters for serie

Details

When type='polygon', coordinates of the two boundaries are chained into a polygon and displayed as one.
When type='stack', two stacked lines are drawn, one with customizable areaStyle. The upper boundary coordinates should be values added on top of the lower boundary coordinates.
Type 'stack' needs xAxis to be of type 'category'.

Value

A list of one serie when type='polygon', or two series when type='stack'

Examples

if (interactive()) {
df <- airquality |> dplyr::mutate(lwr= round(Temp-Wind*2), 
                                  upr= round(Temp+Wind*2), 
                                  x=paste0(Month,'-',Day) ) |>
                    dplyr::relocate(x,Temp)
bands <- ecr.band(df, 'lwr', 'upr', type='stack', 
                  name='stak', areaStyle= list(opacity=0.4))
p <- df |> ec.init(load='custom')
p$x$opts$xAxis <- list(type='category', boundaryGap=FALSE)
p$x$opts$series <- list(list(type='line', color='blue', name='line'), 
                        bands[[1]], bands[[2]] )
p$x$opts$tooltip <- list(trigger= 'axis',
   formatter= ec.clmn('high <b>%@</b><br>line <b>%@</b><br>low <b>%@</b>', 
        3.3, 1.2, 2.2))  # 3.3= upper-serie index .index of column inside
p$x$opts$legend <- list(show= TRUE)
p
}


echarty documentation built on April 1, 2022, 9:06 a.m.