# NOT RUN {
# }
# NOT RUN {
library(shiny)
library(rAmCharts)
# 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))
# 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),
ZoomButton = reactive(data.frame(Unit = c("DD", "DD", "MAX"),
multiple = c(1, 7 ,1), label = c("Day","Week", "MAX"),
selected = c(F, F, T)))
)
# show module return and print ts
output$ts <- renderText({
print(res())
paste0("Current ts : ", res()$ts)
})
}
# Run the application
shinyApp(ui = ui, server = server)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab