@nirgrahamuk, for output, the ui.R code is below:
source("app.R")
library(shiny)
library(timevis)
# Define UI for application that draws a histogram
shinyUI(fluidPage(
# Adiciona as abas
navbarPage("Gráficos",
tabPanel("Gráfico por processo",
sidebarLayout(
sidebarPanel(
dateInput("date1", "Escolha uma data:", format = "dd/mm/yyyy", language = "pt-BR", width = "150px"),
selectInput("select1", "Escolha um processo:", dfLog3$NM_ENVIRONMENT, selected = NULL, width = "150px"),
actionButton(inputId = "go2", label = "Atualizar", icon("refresh"), width = "150px", height = "200"),
div(style="display: inline-block;vertical-align:top; width: 200px;",HTML("<br>")),
dateRangeInput("daterange1", "Escolha um período:", start = Sys.Date()-1, end = Sys.Date(), format = "dd/mm/yy", separator = " - ", width = "170px", language = "pt-BR"),
width = 2),
mainPanel(timevisOutput("app1"), width = 10)
)),
tabPanel("Gráfico por sistema",
sidebarLayout(
sidebarPanel(
dateInput("date1", "Escolha uma data:", format = "dd/mm/yyyy", language = "pt-BR", width = "150px"),
selectInput("select1", "Escolha um sistema/área:", dfLog4$NM_SYSTEM, selected = NULL, width = "150px"),
actionButton(inputId = "go2", label = "Atualizar", icon("refresh"), width = "150px", height = "200"),
div(style="display: inline-block;vertical-align:top; width: 200px;",HTML("<br>")),
dateRangeInput("daterange1", "Escolha um período:", start = Sys.Date()-1, end = Sys.Date(), format = "dd/mm/yy", separator = " - ", width = "170px", language = "pt-BR"),
width = 2),
mainPanel(timevisOutput("app2"), width = 10)
)),
tabPanel("Gráfico por data",
sidebarLayout(
sidebarPanel(
dateInput("date1", "Escolha uma data:", format = "dd/mm/yyyy", language = "pt-BR", width = "150px"),
dateRangeInput("daterange1", "Escolha um período:", start = Sys.Date()-1, end = Sys.Date(), format = "dd/mm/yy", separator = " - ", width = "170px", language = "pt-BR"),
width = 2),
mainPanel(timevisOutput("app4"), width = 10)
)),
tabPanel("Gráfico por eventos individuais",
timevisOutput("app3"))
)
))
For the server.R the code is below:
library(timevis)
library(shiny)
source("app.R")
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
output$app1 <- renderTimevis(timevis(dataLog,
distinct(dataLogGroups),
showZoom = TRUE,
options = list(orientation = 'top', showCurrentTime = TRUE),
height = 700
) %>% setWindow(Sys.Date() - 1,Sys.Date() + 1))
output$app2 <- renderTimevis(timevis(dataLog2,
distinct(dataLogGroups2),
showZoom = TRUE,
options = list(orientation = 'top', showCurrentTime = TRUE),
height = 700
) %>% setWindow(Sys.Date() - 1,Sys.Date() + 1))
output$app3 <- renderTimevis(timevis(dataLog3,
showZoom = TRUE,
options = list(orientation = 'top', showCurrentTime = TRUE),
height = 700
) %>% setWindow(Sys.Date() - 1,Sys.Date() + 1))
output$app4 <- renderTimevis(timevis(dataLog4,
showZoom = TRUE,
options = list(orientation = 'top', showCurrentTime = TRUE),
height = 700
) %>% setWindow(Sys.Date() - 1,Sys.Date() + 1))
})
For the datalog, the app.R code is below (but the steps to get and transform the dataframe I didn't not paste here):
dataLog <- data.frame(
title = paste("Processo:", c(dfLog3$NM_ENVIRONMENT), sep = " "),
content = c(TemplateProcesso(strftime(dfLog3$DT_TIMESTART, format="%H:%M:%S"), strftime(dfLog3$DT_TIMEEND, format="%H:%M:%S"), dfLog3$QT_PROCEDURE, seconds_to_period((dfLog3$DT_TIMEEND - dfLog3$DT_TIMESTART)), seconds_to_period(dfLog3$QT_TIMESECS))),
start = c(dfLog3$DT_TIMESTART),
end = c(dfLog3$DT_TIMEEND),
#style = c(TemplateCores(nrow(table(dfLog3$NM_ENVIRONMENT)))),
group = c(dfLog3$ID_ENVIRONMENT))
dataLogGroups <- data.frame(
id = c(dfLog3$ID_ENVIRONMENT),
content = c(dfLog3$NM_ENVIRONMENT),
style = "font-weight: bold")
timevis(dataLog,distinct(dataLogGroups),showZoom = TRUE,options = list(orientation = 'top')) %>%
setWindow(Sys.Date() - 1,Sys.Date() + 1) %>%
addCustomTime(Sys.Date() - 1, "yesterday")