ecr.band: Area band

Description Usage Arguments Details Value Examples

Description

A 'custom' serie with lower and upper boundaries

Usage

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

...

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
df <- data.frame( x = 1:10, y = runif(10, 5, 10)) %>%
  dplyr::mutate(lwr = y-runif(10, 1, 3), upr = y+runif(10, 2, 4))

p <- df %>% ec.init(load='custom')
p$x$opts$legend <- list(ey='') 
p$x$opts$xAxis <- list(type='category', boundaryGap=FALSE)
p$x$opts$series <- list(list(type='line', color='yellow', datasetIndex=0, name='line1'))
p$x$opts$series <- append( p$x$opts$series,
     ecr.band(df, 'lwr', 'upr', type='stack', name='stak')
)
p$x$opts$tooltip <- list(trigger = 'axis'
                         ,formatter = htmlwidgets::JS("function(x) {
  let str='high <b>'+x[2].value[2]+'</b><br>line <b>'+x[0].value[1]+
   '</b><br>low <b>'+x[1].value[1]+'</b>';
  return str;
  }"))
p

echarty documentation built on July 30, 2021, 9:09 a.m.

Related to ecr.band in echarty...