From d6ba7b04961b75414954c3b0a2a573c6e1179e2f Mon Sep 17 00:00:00 2001 From: mayerm2 Date: Wed, 27 Jan 2021 19:35:15 -0500 Subject: [PATCH 1/2] keeping inputs constant for week tab --- app.R | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/app.R b/app.R index 5c96f44..e31c66e 100755 --- a/app.R +++ b/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'){ @@ -651,14 +698,14 @@ server <- function(input, output, session) { 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) { @@ -1282,11 +1329,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)) From 9212f6347427c1b6c019d93cdc66ea1a841fe220 Mon Sep 17 00:00:00 2001 From: mayerm2 Date: Sat, 30 Jan 2021 13:15:37 -0500 Subject: [PATCH 2/2] fixing title on daily overview barplot --- app.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app.R b/app.R index e31c66e..7ff64b1 100755 --- a/app.R +++ b/app.R @@ -690,7 +690,7 @@ server <- function(input, output, session) { } } }) - + #week tab output$week_ctrl <- renderUI({ week_dat <- reactive({ @@ -735,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)) +