Learn R Programming

rAmCharts (version 2.1.7)

amTimeSeries: Plotting times series which aggregation

Description

amTimeSeries computes a stock chart.

Usage

amTimeSeries(data, col_date, col_series, main = "", ylab = "",
  color = c("#2E2EFE", "#31B404", "#FF4000", "#AEB404"), bullet = NULL,
  bulletSize = 2, linetype = c(0, 5, 10, 15, 20), linewidth = c(1, 1, 1,
  1, 1, 1), fillAlphas = 0, precision = 1, export = FALSE,
  legend = TRUE, legendPosition = "bottom", legendHidden = FALSE,
  aggregation = c("Average", "Low", "High", "Sum"), maxSeries = 300,
  groupToPeriods = c("ss", "mm", "hh", "DD", "MM", "YYYY"),
  ZoomButton = data.frame(Unit = "MAX", multiple = 1, label = "All"),
  ZoomButtonPosition = "bottom", periodFieldsSelection = FALSE,
  scrollbar = TRUE, scrollbarPosition = "bottom", scrollbarHeight = 40,
  scrollbarGraph = NULL, cursor = TRUE, cursorValueBalloonsEnabled = TRUE,
  creditsPosition = "top-right", group = NULL, is_ts_module = FALSE, ...)

Arguments

data

data.frame, data of graph.

col_date

character name of date column

col_series

character names of series columns

main

character, title.

ylab

character, value axis label.

color

character, color of series (in hexadecimal).

bullet

character, point shape. Possible values are : "diamond", "square", "bubble", "yError", "xError", "round", "triangleLeft", "triangleRight", "triangleUp"

bulletSize

: numeric, size of bullet.

linetype

: numeric, line type, 0 : solid, number : dashed length

linewidth

: numeric, line width.

fillAlphas

: numeric, fill. Between 0 (no fill) to 1.

precision

numeric, default set to 1.

export

logical, default set to FALSE. TRUE to display export feature.

legend

logical, enabled or not legend ? Defaut to TRUE.

legendPosition

character, legend position. Possible values are : "left", "right", "bottom", "top"

legendHidden

logical hide some series on rendering ? Defaut to FALSE

aggregation

character, aggregation type. Possible values are : "Low", "High", "Average" and "Sum"

maxSeries

numeric Maximum series shown at a time. In case there are more data points in the selection than maxSeries, the chart will group data to longer periods, for example - you have 250 days in the selection, and maxSeries is 150 - the chart will group data to weeks.

groupToPeriods

character, Periods to which data will be grouped in case there are more data items in the selected period than specified in maxSeries property. Possible value are : 'ss', 'mm', 'hh', 'DD', 'MM', 'YYYY'. It's also possible to add multiple like "30mm". Or NULL to disable.

ZoomButton

data.frame, 3 or 4 columns :

  • "Unit" : Character. Times unit. 'ss', 'mm', 'hh', 'DD', 'MM', 'YYYY'

  • "multiple" : Numeric. multiple*unit

  • "label" : Character. button's label

  • "selected" : Boolean. Optional. To set initial selection. (One TRUE, others FALSE)

ZoomButtonPosition

character, zoom button position. Possible values are : "left", "right", "bottom", "top"

periodFieldsSelection

boolean, using zoom button, add also two fields to select period ?

scrollbar

boolean, enabled or not scrollbar ? Defaut to TRUE.

scrollbarPosition

character, scrollbar position. Possible values are : "left", "right", "bottom", "top"

scrollbarHeight

numeric, height of scroll bar. Default : 40.

scrollbarGraph

character, name of serie (column) to print in scrollbar. Defaut to NULL.

cursor

boolean, enabled or not cursor ? Defaut to TRUE.

cursorValueBalloonsEnabled

boolean, if cursor, enabled or not balloons on cursor ? Defaut to TRUE.

creditsPosition

character, credits position. Possible values are : "top-right", "top-left", "bottom-right", "bottom-left"

group

character, like in dygraphs, for synchronization in shiny or rmarkdown.

is_ts_module

boolean. Don't use. For rAmChartsTimeSeriesUI

...

other first level attributes

See Also

Examples

Run this code
# NOT RUN {
data("data_stock_2")
amTimeSeries(data_stock_2, "date", c("ts1", "ts2"))

# }
# NOT RUN {
# upper /lower
data <- data_stock_2[1:50, ]
data$ts1low <- data$ts1-100
data$ts1up <- data$ts1+100

amTimeSeries(data, "date", list(c("ts1low", "ts1", "ts1up"), "ts2"))
amTimeSeries(data, "date", list(c("ts1low", "ts1", "ts1up"), "ts2"), 
 color = c("red", "blue"), bullet = c("round", "square"))


amTimeSeries(data_stock_2, "date", c("ts1", "ts2"), bullet = "round")
amTimeSeries(data_stock_2, "date", c("ts1", "ts2"), bullet = "round",
              groupToPeriods = c('hh', 'DD', '10DD'))

amTimeSeries(data_stock_2, "date", c("ts1", "ts2"), bullet = "round",
              groupToPeriods = c('12hh', 'DD', '10DD'),
              maxSeries = 50)
              
amTimeSeries(data_stock_2, "date", c("ts1", "ts2"), bullet = "round",
             groupToPeriods = c('hh', 'DD', '10DD'),
             linewidth = c(3, 1))
             
amTimeSeries(data_stock_2, "date", c("ts1", "ts2"), aggregation = "Sum")


amTimeSeries(data_stock_2, "date", c("ts1", "ts2"), bullet = "round",
              groupToPeriods = c('12hh', 'DD', '10DD'),
              maxSeries = 50, precision = 5)

amTimeSeries(data_stock_2, "date", c("ts1", "ts2"), bullet =  c("diamond", "square"),
             linetype = 0, bulletSize = c(5, 10),
             groupToPeriods = c('12hh', 'DD', '10DD'),
             maxSeries = 50, aggregation = "Sum")


ZoomButton <- data.frame(Unit = c("DD", "DD", "MAX"), multiple = c(1, 2 ,1),
                        label = c("Day","2 days", "MAX"))
amTimeSeries(data_stock_2, "date", c("ts1", "ts2"), bullet = "round",
             ZoomButton = ZoomButton, main = "My title", ylab = "Interest")
             
amTimeSeries(data_stock_2, "date", c("ts1", "ts2"), bullet = "round",
             ZoomButton = ZoomButton, main = "My title", ylab = "Interest",
             export = TRUE, ZoomButtonPosition = "right",
             legendPosition = "bottom", scrollbarPosition = "top")
         
amTimeSeries(data_stock_2, "date", c("ts1", "ts2"), bullet = "round",
             ZoomButton = ZoomButton, main = "My title",
             ylab = "Interest", export = TRUE,
             creditsPosition = "bottom-left")
             
# }

Run the code above in your browser using DataLab