First, you should load recharts
:
library(recharts)
EventRiver plot contains 1 basic type: eventRiver.
The keys are:
x
must be made of :
y
must be made of:
series
must be made of:
echartr(data, x, y, <t>, <series>, <type>)
Arg | Requirement |
---|---|
data |
source data in the form of data.frame |
x |
character independent variable. It must contain 2 compulsory columns (event slice time, events name) and/or 3 optional columns (event slice title, event slice links, event slice images). The params list must exactly follow this order. |
y |
numeric dependent variable. It must contain 1 compulsory column (slice value) and/or 1 optional column (slice weight). The params list must exactly follow this order. |
t |
timeline variable which will be coerced to factors. Only the first one is accepted if multiple variables are provided. |
series |
data series variable processed as factors. It contains 2 optional columns (series, series weight). The params list must exactly follow this order. |
type |
‘eventRiver’ |
data(events)
events$link <- 'www.baidu.com'
events$img <- 'inst/favicon.png'
events$title <- paste(rownames(events), events$event)
echartr(events, c(time, event, title, link, img), c(value, weight), series,
type='eventRiver') %>%
setTitle('Event River', 'Ficticious Data') %>% setXAxis(name='Time') %>%
setGrid(y2=80)
If you provide more details about each event slice (title, link and image) in x
, the chart will be more informative.
Then you can configure the widgets, add markLines and/or markPoints, fortify the chart.
You can refer to related functions to play around on your own.