First, you should load recharts:


1 Introduction

Candlestick plot is also known as K chart:

The keys are:

  • character x
  • numeric ‘y’ (four columns) aranged in the order of ‘open’, ‘close’, ‘low’, ‘high’

2 Function Call

echartr(data, x, y, <t>, <type>)
Arg Requirement


source data in the form of data.frame


character independent variable. Only the first one is accepted if multiple variables are provided.


numeric dependent variable. Only the first four ones are accepted which are arranged in the order of ‘open’, ‘close’, ‘low’, ‘high’.


timeline variable which will be coerced to factors. Only the first one is accepted if multiple variables are provided.


‘k’ or ‘candlestick’

3 Showcase

3.1 Basic Plot

echartr(stock, as.character(date), c(open, close, low, high), type='k') %>%
    setXAxis(name='Date', axisLabel=list(rotate=30)) %>%

3.2 With Timeline

Remember the special notes in the quick start? We need to supplement the dataset to cover all the x and t levels.

stock$Month <- format(stock$date, '%m')
stock$Day <- format(stock$date, '%d')
fullData <- data.frame(expand.grid(unique(stock$Month), unique(stock$Day)))
names(fullData) <- c("Month", "Day")
stock <- merge(stock, fullData, all.y=TRUE)

Then timeline will work properly.

echartr(stock, Day, c(open, close, low, high), t=Month, type='k') %>%

4 Futher Setup

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.