rAmCharts - amCandlestick

Parameters

  • data: a dataframe with at least 5 columns: category, open (numeric), close (numeric), low (numeric), high (numeric).
  • dataDateFormat: a character, default ‘NULL’. Even if your chart parses dates, you can pass them as strings in your data - all you need to do is to set data date format and the chart will parse dates to date objects. Please note that two-digit years (YY) as well as literal month names (MMM) are NOT supported in this setting.
  • minPeriod: a character. minPeriod Specifies the shortest period of your data. This should be set only if dataDateFormat is not ‘NULL’. Possible period values: fff - milliseconds, ss - seconds, mm - minutes, hh - hours, DD - days, MM - months, YYYY - years. It’s also possible to supply a number for increments, i.e. ‘15mm’ which will instruct the chart that your data is supplied in 15 minutes increments.
  • positiveColor: a character, color for positive values. Must be in hexadecimal if you plan to export the chart.
  • negativeColor: a character, color for negative values. Must be in hexadecimal if you plan to export the chart.
  • names: a character, names for the tooltips.
  • xlab: a character, label for x-axis.
  • ylab: a character, label for y-axis.
  • horiz: a boolean, TRUE for an horizontal chart, FALSE for a vertical one.
  • : other parameters called in amOptions.

Data used in the examples:

data("data_candleStick2")
head(data_candleStick2)
##     category   open close    low   high
## 1 2015-01-01 136.65 136.4 134.15 136.96
## 2 2015-01-02 135.26 131.8 131.50 135.95
## 3 2015-01-03 132.90 135.2 128.30 135.27
## 4 2015-01-04 134.94 135.0 132.63 137.24
## 5 2015-01-05 136.76 134.0 132.00 136.86
## 6 2015-01-06 131.11 126.3 125.09 133.00

Reference example

amCandlestick(data = data_candleStick2, labelRotation = -45)

Change colors

amCandlestick(data = data_candleStick2, positiveColor = "black", negativeColor = "green", 
              labelRotation = -45)

Naming axis

amCandlestick(data = data_candleStick2, ylab = "values", 
              labelRotation = -45)

Rotate x axis labels

amCandlestick(data = data_candleStick2, labelRotation = 90)

Change names

amCandlestick(data = data_candleStick2, names = c("min", "begin", "end", "max"), 
              labelRotation = -45)

Horizontal chart

amCandlestick(data = data_candleStick2, horiz = TRUE)

Parse dates

amCandlestick(data = data_candleStick2, dataDateFormat = "YYYY-MM-DD", 
              labelRotation = -45)

Data over months

data_candleStick2$category <- c("2015-01-01", "2015-02-01", "2015-03-01",
                                "2015-04-01", "2015-05-01", "2015-06-01",
                                "2015-07-01", "2015-08-01", "2015-09-01",
                                "2015-10-01", "2015-11-01", "2015-12-01")

amCandlestick(data = data_candleStick2, dataDateFormat = "YYYY-MM-DD", minPeriod = "MM", 
              labelRotation = -45)

amOptions

export

amCandlestick(data = data_candleStick2, export = TRUE, labelRotation = -45)
#or
amCandlestick(data = data_candleStick2, labelRotation = -45) %>>% 
  amOptions(export = TRUE)

exportFormat

amCandlestick(data = data_candleStick2, export = TRUE, exportFormat = "JPG", 
              labelRotation = -45)
#or
amCandlestick(data = data_candleStick2, labelRotation = -45) %>>% 
  amOptions(export = TRUE, exportFormat = "JPG")

main and creditsPosition

amCandlestick(data = data_candleStick2, main = "My Candlestick",
        mainColor = "#68838B", mainSize = 25, creditsPosition = "top-right", 
        labelRotation = -45)
#or
amCandlestick(data = data_candleStick2, labelRotation = -45) %>>% 
  amOptions( main = "My Candlestick",
        mainColor = "#68838B", mainSize = 25, creditsPosition = "top-right")

theme

amCandlestick(data = data_candleStick2, theme = "patterns",
              labelRotation = -45)
#or
amCandlestick(data = data_candleStick2, labelRotation = -45) %>>% 
  amOptions(theme = "patterns")