From e474b9911686fa9b4688dcba6a5cf36f85397f3c Mon Sep 17 00:00:00 2001
From: Thomas Rushby <t.w.rushby@soton.ac.uk>
Date: Mon, 5 Oct 2020 20:44:33 +0100
Subject: [PATCH] Set default local auth area.

---
 howTo/openGeogAPI/app.R | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/howTo/openGeogAPI/app.R b/howTo/openGeogAPI/app.R
index 44f359e..1440176 100644
--- a/howTo/openGeogAPI/app.R
+++ b/howTo/openGeogAPI/app.R
@@ -170,9 +170,15 @@ server <- function(input, output, session) {
                            "\nLocal authority boundary data (2018): ONS Open Geography Portal",
                            "\nVisualisation: rushby.shinyapps.io/LAemissions")
       
-      plotTitle = paste0("Greenhouse gas emissions by sector for ",input$authmap_shape_click$id)
+      if(is.null(input$authmap_shape_click$id)){
+        auth_area  <-  "Southampton"
+      } else {
+        auth_area  <-  input$authmap_shape_click$id
+      }
+      
+      plotTitle = paste0("Greenhouse gas emissions by sector for ",auth_area)
       
-      ggplot(ghg_subset(auth_area = input$authmap_shape_click$id), aes(x = Year, y = value)) +
+      ggplot(ghg_subset(auth_area = auth_area), aes(x = Year, y = value)) +
         geom_col(aes(fill = variable), position = "stack") +
         scale_x_continuous(limits = c(x_min-1,x_max+1), breaks = x_min:x_max) +
         #scale_y_continuous(limits = c(y_min,y_max)) +
-- 
GitLab