Skip to content
Permalink
Browse files
Merge pull request #12 from DataINCITE/darl-mayerm2
fixing bug with keeping inputs constant for week tab
  • Loading branch information
erickj4 committed Jan 30, 2021
2 parents 47ac11a + 9212f63 commit 5810da527e5bbcea6c9fc620216c48a9c570e106
Showing 1 changed file with 55 additions and 8 deletions.
63 app.R
@@ -539,6 +539,23 @@ server <- function(input, output, session) {
}
updateSelectInput(session, "buildingStr_discrete",choices = buildingname,selected=abbreviation)
}
# If user was jumping to Daily Overview, then input date, time should be same as map's, and marker should be clicked
if((!(input$buildingStr_week == abbreviation)||!(identical(input$buildingType_week, input$buildingtype))||!(identical(input$data_type_week,input$datatype))) &&
!is.null(input$bubblemap_marker_click)){
updateRadioButtons(session, "data_type_week", selected=input$datatype)
updateCheckboxGroupInput(session, "buildingType_week", selected = input$buildingtype)
# If users do not select any building type, plot should show all the data;
# The dropdown should include all the buildings.
if(!is.null(input$buildingType_week)){
buildingtype<-input$buildingType_week
buildingname<-alltype[buildingtype]
buildingname<-c("Buildings from selected building type(s)"="all",buildingname)
}
else{
buildingname<-c("Buildings from selected building type(s)"="all",alltype)
}
updateSelectInput(session, "buildingStr_week",choices = buildingname,selected=abbreviation)
}
}
# when the users change input at the Detailed Wifi Overview tab
else if(input$tabs=='continuous'){
@@ -569,6 +586,22 @@ server <- function(input, output, session) {
}
updateSelectInput(session, "buildingStr_discrete",choices = buildingname,selected=building_info)
}
# update the input in the Daily Overview tab consistently with the Detailed Wifi Overview tab
if(!(input$data_type_week == data_type_info)||!(identical(input$buildingType_week,building_type_info))||!(input$buildingStr_week==building_info)){
updateRadioButtons(session, "data_type__week", selected=data_type_info)
updateCheckboxGroupInput(session, "buildingType_week", selected = building_type_info)
# If users do not select any building type, plot should show all the data;
# The dropdown should include all the buildings.
if(!is.null(input$buildingType_week)){
buildingtype<-input$buildingType_week
buildingname<-alltype[buildingtype]
buildingname<-c("Buildings from selected building type(s)"="all",buildingname)
}
else{
buildingname<-c("Buildings from selected building type(s)"="all",alltype)
}
updateSelectInput(session, "buildingStr_week",choices = buildingname,selected=building_info)
}

}
# when the users change input at the Campus Wifi Dashboard tab
@@ -600,6 +633,20 @@ server <- function(input, output, session) {
}
updateSelectInput(session, "buildingStr",choices = buildingname,selected=building_info)
}
# update the input in the Daily Overview tab consistently with the Campus Wifi Dashboard tab
if(!(input$data_type_week == data_type_info)||!(identical(input$buildingType_week,building_type_info))||!(input$buildingStr_week==building_info)){
updateRadioButtons(session, "data_type_week", selected=data_type_info)
updateCheckboxGroupInput(session, "buildingType_week", selected = building_type_info)
if(!is.null(input$buildingType_week)){
buildingtype<-input$buildingType_week
buildingname<-alltype[buildingtype]
buildingname<-c("Buildings from selected building type(s)"="all",buildingname)
}
else{
buildingname<-c("Buildings from selected building type(s)"="all",alltype)
}
updateSelectInput(session, "buildingStr_week",choices = buildingname,selected=building_info)
}
}
# when the users change input at the Week Overview tab
else if(input$tabs=='week'){
@@ -643,22 +690,22 @@ server <- function(input, output, session) {
}
}
})

#week tab
output$week_ctrl <- renderUI({
week_dat <- reactive({
if (input$data_type_week == "user"){
range <- input$daterange
rpi_wap_raw <- rpi_wap_raw %>% filter(buildingType %in% input$buildingType_week) %>%
filter(abbrev == input$buildingStr_week) %>% filter(Date >= range[1]) %>%
filter(Date <= range[2]) %>% group_by(Date, abbrev, Building, buildingType) %>%
summarize(day_sum = sum(usercount))
filter(Date <= range[2]) %>% dplyr::group_by(Date) %>%
dplyr::summarize(day_sum = sum(usercount))
}
else{
rpi_wap_raw <- rpi_wap_raw %>% filter(buildingType %in% input$buildingType_week) %>%
filter(abbrev == input$buildingStr_week) %>% filter(Date >= range[1]) %>%
filter(Date <= range[2]) %>% group_by(Date, abbrev, Building, buildingType) %>%
summarize(day_sum = sum(maccount))
filter(Date <= range[2]) %>% dplyr::group_by(Date, abbrev, Building, buildingType) %>%
dplyr::summarize(day_sum = sum(maccount))
}
})
set_breaks = function(max_y) {
@@ -688,13 +735,15 @@ server <- function(input, output, session) {
})

observe({
names <- buildinginfo %>% filter(abbrev == input$buildingStr_week)
fullname <- names$Building
output$barplot <- renderPlot({
max_y <- max(week_dat()$day_sum)
ggplot(week_dat(), aes(x=Date, y=day_sum, fill=day_sum)) +
geom_bar(stat="identity") +
xlab(label = "Day of the Week") +
ylab(label = "Total WiFi Access") +
ggtitle(paste("WiFi Access from ", input$daterange[1], "to ", input$daterange[2], "for ", week_dat()$Building[1]))+
ggtitle(paste("WiFi Access from", input$daterange[1], "to", input$daterange[2], "for", fullname))+
theme_bw() +
scale_fill_distiller(palette = "Purples", direction = "horizontal", name = "Count",
breaks = set_breaks(max_y)) +
@@ -1282,11 +1331,9 @@ server <- function(input, output, session) {
max_count<-dat()[!duplicated(dat()$devname),]
hottest_time<-dat()[dat()$usercount==dat()$max_count,]
hottest_time<-hottest_time[!duplicated(hottest_time$devname),]$date_time
print(hottest_time)
cont_table<-data.frame("Devname"=(max_count$devname),"max_building_user"=(max_count$max_count),"Hottest Time"=hottest_time)
names(cont_table)[names(cont_table) == "max_building_user"]=max_building_user
rownames(cont_table) <- NULL
print(cont_table)
cont_table
}
},options = list(searching = FALSE))

0 comments on commit 5810da5

Please sign in to comment.