Skip to contents

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 of band's lower boundary (string).

upper

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

type

Type of rendering

  • 'polygon' - by drawing a polygon as polyline from upper/lower points (default)

  • 'stack' - by two stacked lines

...

More attributes for serie

Value

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

Details

  • type='polygon': coordinates of the two boundaries are chained into one polygon.
    xAxis type could be 'category' or 'value'.
    Set fill color with attribute color.

  • type='stack': two stacked lines are drawn, the lower with customizable areaStyle.
    xAxis type should be 'category' !
    Set fill color with attribute areaStyle$color.
    Optional tooltip formatter available in band[[1]]$tipFmt.

Optional parameter name, if given, will show up in legend. Legend merges all series with same name into one item.

Examples

set.seed(222)
df <- data.frame( x = 1:10, y = round(runif(10, 5, 10),2)) |>
  dplyr::mutate(lwr= round(y-runif(10, 1, 3),2), upr= round(y+runif(10, 2, 4),2) )
banda <- ecr.band(df, 'lwr', 'upr', type='stack', name='stak', areaStyle= list(color='green'))
#banda <- ecr.band(df, 'lwr', 'upr', type='polygon', name='poly1')

df |> ec.init( load='custom', # polygon only
  legend= list(show= TRUE),
  xAxis= list(type='category', boundaryGap=FALSE), # stack
  #xAxis= list(scale=T, min='dataMin'),            # polygon 
  series= append(
    list(list(type='line', color='blue', name='line1')),
    banda
  ),
  tooltip= list(trigger='axis', formatter= banda[[1]]$tipFmt)
)