rAmCharts - amOHLC

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

amOHLC(data = data_candleStick2, labelRotation = -45)

Change colors

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

Naming axis

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

Rotate x axis labels

amOHLC(data = data_candleStick2, labelRotation = 90)

Change names

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

Horizontal chart

amOHLC(data = data_candleStick2, horiz = TRUE)

Parse dates

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

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")

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

amOptions

export

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

exportFormat

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

main and creditsPosition

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