rAmCharts - amTimeSeries

Usage

amTimeSeries can be use to visualize times series which differents aggregation scale. You can pass minutes data and visualize your serie aggregate by hour or day for example. Three parameters control aggregation. groupToPeriods reference all periods or times series can be aggregated. maxSeries control maximum of points displayed before next period. aggregation control the type of aggregation, can be a sum, a mean …

Parameters

  • data: a data.frame, data of graph.
  • col_date: a character, name of date column.
  • col_series: a character, names of series columns.
  • main: a character, title of graph.
  • ylab: a character, value axis label.
  • color: a character, color of series (in hexadecimal).
  • bullet: a character, point shape. Possible values are : “diamond”, “square”, “bubble”, “yError”, “xError”, “round”, “triangleLeft”, “triangleRight”, “triangleUp”.
  • bullet: a numeric, size of bullet.
  • linetype: a numeric, line type, 0 will draw a solid line, number will draw a dashed length.
  • linewidth: a numeric, line width.
  • fillAlphas: a numeric, between 0 and 1.
  • precision: a numeric, default set to 1.
  • export: a logical, default set to FALSE. TRUE to display export feature.
  • legend: a logical, enabled or not legend ? Defaut to TRUE.
  • legendPosition: a character, legend position. Possible values are : “left”, “right”, “bottom”, “top”.
  • aggregation: a character, aggregation type. Possible values are : “Low”, “High”, “Average” and “Sum”.
  • maxSeries: a 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: a 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”.
  • ZoomButton: a data.frame, 3 columns : Unit, times unit. multiple : multiple*unit. label : button’s label
  • ZoomButtonPosition: a character, zoom button position. Possible values are : “left”, “right”, “bottom”, “top”.
  • scrollbar: a boolean, enabled or not scrollbar ? Defaut to TRUE.
  • scrollbarPosition: a character, scrollbar position. Possible values are : “left”, “right”, “bottom”, “top”.
  • scrollbarHeight: a numeric, height of scroll bar. Default : 40.
  • creditsPosition: a character, credits position. Possible values are : “top-right”, “top-left”, “bottom-right”, “bottom-left”.
  • group: a character, like in dygraphs, for synchronization in shiny or rmarkdown.
  • : other first level attributes

Reference example

   data('data_stock_2')
   amTimeSeries(data_stock_2, 'date', c('ts1', 'ts2'))

Style and aggregate period

    data('data_stock_2')
    amTimeSeries(data_stock_2, 'date', c('ts1', 'ts2'), bullet = 'round',
             groupToPeriods = c('hh', 'DD', '10DD'),
             linewidth = c(3, 1))

Confidence interval

    data("data_stock_2")
    data_stock_2 <- data_stock_2[1:50, ]
    data_stock_2$ts1low <- data_stock_2$ts1-100
    data_stock_2$ts1up <- data_stock_2$ts1+100
    amTimeSeries(data_stock_2, "date", list(c("ts1low", "ts1", "ts1up"), "ts2"), 
                color = c("red", "blue"), bullet = c("round", "square"))

Aggregation type, legend and number max of points before aggregate, group with next graph

  data('data_stock_2')
  amTimeSeries(data_stock_2, 'date', c('ts1', 'ts2'), aggregation = 'Sum', legend = TRUE,
              maxSeries = 1300, group = 'a')

More options…, group with previous graph

  data('data_stock_2')
    ZoomButton <- data.frame(Unit = c('DD', 'DD', 'MAX'), multiple = c(1, 10 ,1),
                     label = c('Day','10 days', 'MAX'))
    amTimeSeries(data_stock_2, 'date', c('ts1', 'ts2'), bullet = 'round',
                ZoomButton = ZoomButton, main = 'My title',
                ylab = 'Interest', export = TRUE,
                creditsPosition = 'bottom-left', group = 'a')