Learn R Programming

echarts4r (version 0.1.1)

e_candle: Candlestick

Description

Add a candlestick chart.

Usage

e_candle(e, opening, closing, low, high, bind, name = NULL,
  legend = TRUE, ...)

e_candle_(e, opening, closing, low, high, bind = NULL, name = NULL, legend = TRUE, ...)

Arguments

e

An echarts4r object as returned by e_charts.

opening, closing, low, high

Stock prices.

bind

Binding between datasets, namely for use of e_brush.

name

name of the serie.

legend

Whether to add serie to legend.

...

Any other option to pass, check See Also section.

See Also

https://ecomfe.github.io/echarts-doc/public/en/option.html#series-candlestick

Examples

Run this code
# NOT RUN {
date <- c("2017-01-01", "2017-01-02", "2017-01-03", "2017-01-04", "2017-03-05", 
         "2017-01-06", "2017-01-07")
         
stock <- data.frame(
  date = date,
  opening = c(200.60, 200.22, 198.43, 199.05, 203.54, 203.40, 208.34),
  closing = c(200.72, 198.85, 199.05, 203.73, 204.08, 208.11, 211.88),
  low = c(197.82, 198.07, 197.90, 198.10, 202.00, 201.50, 207.60),
  high = c(203.32, 200.67, 200.00, 203.95, 204.90, 208.44, 213.17)
)

stock %>% 
  e_charts(date) %>% 
  e_candle(opening, closing, low, high) %>% 
  e_y_axis(min = 190, max = 220)
  
# }

Run the code above in your browser using DataLab