Description Usage Arguments See Also Examples
Add candlestick bars.
1 2 3 4 5 |
p |
an echart object. |
opening, closing, low, high |
stock prices. |
name |
name of serie. |
clickable |
whether serie is clickable. |
z, zlevel |
first and second grade cascading control, the higher z the closer to the top. |
... |
any other options to pass to candlessticks. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # generate data
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))
js <- htmlwidgets::JS("function(params){
var res = 'opening: ' + params.value[0] + '<br>' + 'closing: ' + params.value[3];
return res}")
stock %>%
echart(date) %>%
ecandle(opening, closing, low, high, barMaxWidth = 20) %>%
etooltip(trigger = "item", formatter = js) %>%
etheme("macarons")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.