ecr.band | R Documentation |
A 'custom' serie with lower and upper boundaries
ecr.band(df = NULL, lower = NULL, upper = NULL, type = "stack", ...)
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
|
... |
More parameters for serie |
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.
A list of one serie when type='polygon', or two series when type='stack'
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
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.