Commit 8a9822cf authored by Charles's avatar Charles

move app files in specific directory

parent 69cc16ac
......@@ -6,6 +6,13 @@ import(shiny)
importFrom(DBI,dbGetQuery)
importFrom(data.table,":=")
importFrom(data.table,data.table)
importFrom(dygraphs,dyOptions)
importFrom(dygraphs,dyRangeSelector)
importFrom(dygraphs,dygraph)
importFrom(dygraphs,dygraphOutput)
importFrom(dygraphs,renderDygraph)
importFrom(golem,with_golem_options)
importFrom(magrittr,'%>%')
importFrom(pool,dbPool)
importFrom(pool,poolClose)
importFrom(shiny,shinyApp)
......@@ -3,17 +3,23 @@
#' @importFrom pool dbPool
#' @importFrom DBI dbGetQuery
#' @importFrom data.table data.table ":="
#' @importFrom dygraphs dygraph dyRangeSelector renderDygraph
#' @importFrom magrittr '%>%'
app_server <- function(input, output, session) {
output$dispo_over_time <- renderPlot({
output$dispo_over_time <- renderDygraph({
q <- paste0("SELECT last_update_fme, available_bikes ",
"FROM dispo ",
"WHERE number = ", input$number_choice)
dt <- data.table(dbGetQuery(pool, q))
# browser()
dt[, last_update_fme := as.POSIXct(last_update_fme)]
ggplot(dt, aes(x = last_update_fme, y = available_bikes)) +
geom_line()
dygraph(dt,
main = paste0("Disponibilité Vélo'v pour la station ",
input$number_choice)) %>%
dyRangeSelector %>%
dyOptions(colors = "#00225F")
})
}
#' @import shiny
#' @importFrom DBI dbGetQuery
#' @importFrom dygraphs dygraphOutput dyOptions
app_ui <- function() {
q <- "SELECT DISTINCT number FROM dispo"
choices <- dbGetQuery(pool, q)$number
q <- "SELECT DISTINCT name FROM dispo"
choices <- dbGetQuery(pool, q)$name
tagList(
# Leave this function for adding external resources
golem_add_external_resources(),
......@@ -11,7 +14,7 @@ app_ui <- function() {
h1("rvelov"),
selectInput("number_choice", "Number:",
choices = choices),
plotOutput("dispo_over_time")
dygraphOutput("dispo_over_time", height = "600px")
)
)
}
......
......@@ -3,6 +3,7 @@
#' @export
#' @importFrom shiny shinyApp
#' @importFrom golem with_golem_options
#' @importFrom pool poolClose
run_app <- function(...) {
pool <<- dbPool(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment