rAmCharts-shinymodules-ts {rAmCharts} | R Documentation |
Shiny module to render large time-series data with live server-client aggregation
Description
Shiny module to render large time-series data with live server-client aggregation
Usage
rAmChartsTimeSeriesUI(id, width = "100%", height = "400px")
rAmChartsTimeSeriesServer(
input,
output,
session,
data,
col_date,
col_series,
maxPoints = shiny::reactive(600),
tz = shiny::reactive("UTC"),
ts = shiny::reactive(c("5 min", "10 min", "30 min", "hour", "3 hour", "12 hour",
"day", "week", "month", "year")),
fun_aggr = shiny::reactive("mean"),
treat_missing = shiny::reactive(FALSE),
maxgap = shiny::reactive(Inf),
type_aggr = shiny::reactive("first"),
na.rm = shiny::reactive(TRUE),
main = shiny::reactive(""),
ylab = shiny::reactive(""),
color = shiny::reactive(c("#2E2EFE", "#31B404", "#FF4000", "#AEB404")),
type = shiny::reactive(c("line")),
bullet = shiny::reactive(NULL),
bulletSize = shiny::reactive(2),
linetype = shiny::reactive(c(0, 5, 10, 15, 20)),
linewidth = shiny::reactive(c(1, 1, 1, 1, 1, 1)),
fillAlphas = shiny::reactive(0),
precision = shiny::reactive(1),
connect = shiny::reactive(FALSE),
export = shiny::reactive(FALSE),
legend = shiny::reactive(TRUE),
legendPosition = shiny::reactive("bottom"),
legendHidden = shiny::reactive(FALSE),
ZoomButton = shiny::reactive(data.frame(Unit = "MAX", multiple = 1, label = "All")),
ZoomButtonPosition = shiny::reactive("bottom"),
periodFieldsSelection = shiny::reactive(FALSE),
scrollbar = shiny::reactive(TRUE),
scrollbarPosition = shiny::reactive("bottom"),
scrollbarHeight = shiny::reactive(40),
scrollbarGraph = shiny::reactive(NULL),
cursor = shiny::reactive(TRUE),
cursorValueBalloonsEnabled = shiny::reactive(TRUE),
creditsPosition = shiny::reactive("top-right"),
group = shiny::reactive(NULL),
dataDateFormat = shiny::reactive("YYYY-MM-DD JJ:NN:ss"),
categoryBalloonDateFormats = shiny::reactive(list(list(period = "YYYY", format =
"YYYY"), list(period = "MM", format = "YYYY-MM"), list(period = "WW", format =
"YYYY-MM-DD"), list(period = "DD", format = "YYYY-MM-DD"), list(period = "hh", format
= "YYYY-MM-DD JJ:NN"), list(period = "mm", format = "YYYY-MM-DD JJ:NN"), list(period
= "ss", format = "YYYY-MM-DD JJ:NN:ss"), list(period = "fff", format =
"YYYY-MM-DD JJ:NN:ss"))),
dateFormats = shiny::reactive(list(list(period = "YYYY", format = "YYYY"),
list(period = "MM", format = "MMM"), list(period = "WW", format = "MMM DD"),
list(period = "DD", format = "MMM DD"), list(period = "hh", format = "JJ:NN"),
list(period = "mm", format = "JJ:NN"), list(period = "ss", format = "JJ:NN:ss"),
list(period = "fff", format = "JJ:NN:ss"))),
thousandsSeparator = shiny::reactive(" "),
decimalSeparator = shiny::reactive("."),
balloonFontSize = shiny::reactive(10),
balloonMaxWidth = shiny::reactive(400)
)
Arguments
id |
character, used to specify namesapce, see |
width |
|
height |
|
input |
standard, |
output |
standard, |
session |
standard, |
data |
: data.frame to transform. |
col_date |
Date column name, default to "date". Must be "POSIXct" |
col_series |
Column name of quantitative variable(s) to be transformed. Default to setdiff(colnames(data), "date") |
maxPoints |
: Maximal number of rows in results |
tz |
: Timezone of result. Defaut to "UTC". |
ts |
All enabled aggregation. Default to c("5 min", "10 min", "30 min", "hour", "3 hour", "12 hour", "day", "week", "month", "year"). Can be a number, in seconds, or a character string containing one of "min", "hour", "day".... This can optionally be preceded by a positive integer and a space |
fun_aggr |
: Aggregation function to use ("min", "max", "sum", "mean", "first", "last", "minabs", "maxabs"). Default to "mean". |
treat_missing |
: Boolean. Default to FALSE
Whether or not to interpolate missing values ?
see |
maxgap |
When interpolate missing values with |
type_aggr |
|
na.rm |
: aggregation only. a logical value indicating whether NA values should be stripped before the computation proceeds. |
main |
|
ylab |
|
color |
|
type |
|
bullet |
|
bulletSize |
|
linetype |
|
linewidth |
|
fillAlphas |
|
precision |
|
connect |
|
export |
|
legend |
|
legendPosition |
|
legendHidden |
|
ZoomButton |
|
ZoomButtonPosition |
|
periodFieldsSelection |
|
scrollbar |
|
scrollbarPosition |
|
scrollbarHeight |
|
scrollbarGraph |
|
cursor |
|
cursorValueBalloonsEnabled |
|
creditsPosition |
|
group |
|
dataDateFormat |
|
categoryBalloonDateFormats |
|
dateFormats |
|
thousandsSeparator |
|
decimalSeparator |
|
balloonFontSize |
|
balloonMaxWidth |
|
Value
a reactive expression with aggregate data and ts
Examples
## Not run:
library(shiny)
library(rAmCharts)
library(data.table)
# number of points
n <- 1000000
data <- data.frame(date = seq(c(ISOdate(1999,12,31)), by = "5 min", length.out = n),
value = rnorm(n, 100, 50), check.names = FALSE)
# maximun of points in javascript
max_points <- 1000
# Call module in UI
ui <- fluidPage(
rAmChartsTimeSeriesUI("ts_1", height = "600px"),
h4(textOutput("ts"))
)
# Define server
server <- function(input, output) {
# Call module in server
res <- callModule(rAmChartsTimeSeriesServer, "ts_1", reactive(data), reactive("date"),
reactive("value"), maxPoints = shiny::reactive(max_points),
main = reactive("Example of rAmChartsTimeSeries module"),
color = reactive("red"), periodFieldsSelection = reactive(TRUE)
)
# show module return and print ts
output$ts <- renderText({
print(res())
paste0("Current ts : ", res()$ts)
})
}
# Run the application
shinyApp(ui = ui, server = server)
## End(Not run)