ecr.band {echarty}R 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 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

Details

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

Value

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

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)
)


[Package echarty version 1.6.4 Index]