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 = "stack", ...)

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

  • 'stack' - by two stacked lines (default)

  • 'polygon' - by drawing a polygon as polyline from upper/lower points.

...

More parameters for serie

Details

  • type='stack': two stacked lines are drawn, one with customizable areaStyle. The upper boundary coordinates are values added on top of the lower boundary coordinates.
    xAxis is required to be of type 'category'.

  • type='polygon': coordinates of the two boundaries are chained into a polygon and displayed as one. Tooltips do not show upper band values.

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

Value

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

Examples

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))
df |> ec.init( load= 'custom',
   legend= list(show= TRUE),
   dataZoom= list(type= 'slider'),
   toolbox= list(feature= list(dataZoom= list(show= TRUE))),
   xAxis= list(type= 'category', boundaryGap= FALSE),
   series= list(
     list(type='line', color='blue', name='line'),
     bands[[1]], bands[[2]]
   ),
   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
)


echarty documentation built on Sept. 21, 2023, 1:06 a.m.

Related to ecr.band in echarty...