Browse Source

Styling, more information

* search shortcut
* fix gradient on some browsers
* Explain data source
Petra Lamborn 3 years ago
parent
commit
4884e2a354
2 changed files with 70 additions and 13 deletions
  1. 5
    4
      viz/app.R
  2. 65
    9
      viz/extras.R

+ 5
- 4
viz/app.R View File

@@ -48,6 +48,7 @@ ui <- fluidPage(
48 48
   useShinyjs(),
49 49
   leafletjs,
50 50
   keyboardjs,
51
+  shiny::tags$title("How did Kiwis commute in 2018?"),
51 52
   tags$style(type = "text/css", extracss),
52 53
   
53 54
   leafletOutput("map"),
@@ -65,8 +66,8 @@ ui <- fluidPage(
65 66
                              inline = TRUE),
66 67
                 radioButtons("radioinout", label="Show commuters who",
67 68
                              choiceNames = list(
68
-                           HTML("Commute <span class='shortcut'>f</span>rom selected area"),
69
-                           HTML("Commute <span class='shortcut'>t</span>o selected area")),
69
+                   HTML("Commute <span class='shortcut'>f</span>rom selected area"),
70
+                   HTML("Commute <span class='shortcut'>t</span>o selected area")),
70 71
                              choiceValues = list(
71 72
                                "res",
72 73
                                "work"
@@ -75,8 +76,8 @@ ui <- fluidPage(
75 76
                 radioButtons("radiocolour",
76 77
                              label = "Colour by",
77 78
                              choiceNames = list(
78
-                           HTML("M<span class='shortcut'>o</span>st common commute method"),
79
-                           HTML("N<span class='shortcut'>u</span>mber of commuters")
79
+                   HTML("M<span class='shortcut'>o</span>st common commute method"),
80
+                   HTML("N<span class='shortcut'>u</span>mber of commuters")
80 81
                              ),
81 82
                              choiceValues = list(
82 83
                                "type",

+ 65
- 9
viz/extras.R View File

@@ -96,8 +96,7 @@ blockquote {
96 96
   left:0;
97 97
   bottom:5px;
98 98
   right:0;
99
-  background:linear-gradient(transparent 0px, 
100
-    rgba(255, 255, 255, 0.9));
99
+  background:linear-gradient(rgba(255, 255, 255, 0) 0px, rgba(255, 255, 255, 0.9));
101 100
 }
102 101
 #infobuttoncontainer label {
103 102
   font-weight: bold;
@@ -123,14 +122,25 @@ hr {
123 122
   columns: 20em 2;
124 123
 }
125 124
 kbd {
126
-  color: #444;
125
+  color: black;
127 126
   background-color: #eee;
128 127
   border-radius: 4px;
129
-  padding: 0px 2px;
128
+  padding: 1px 6px;
130 129
   border-color: #444;
131 130
   border-width: 1px;
132 131
   -webkit-box-shadow: 1px 1px #444;
133 132
   box-shadow: 1px 1px #444;
133
+  font-size: 120%;
134
+  font-family: arial, Helvetica, sans-serif;
135
+  cursor: pointer;
136
+}
137
+kbd:hover {
138
+    background-color: #ddd;
139
+    box-shadow: 0.5px 0.5px;
140
+    -webkit-box-shadow: 0.5px 0.5px;
141
+}
142
+#infoint li {
143
+  padding-bottom: 10px;
134 144
 }
135 145
 "
136 146
 
@@ -159,14 +169,38 @@ infotext <- div(class="overflowable", id="infoint", tabindex="2",
159 169
     a(href=
160 170
 "https://www.stats.govt.nz/2018-census/there-and-back-
161 171
 again-data-visualisation-competition", "data visualisation competition",
162
-    .noWS = "after"), ". The employment data counts employed persons 15 years or ",
172
+    .noWS = "after"), 
173
+    HTML(". The employment data counts employed persons 15 years or ",
163 174
     "older who gave an employment location in the 2018 census, while the ",
164 175
     "education data counts people in education 15 years or older who gave an ",
165 176
     "education location in the 2018 census—including older highschoolers and ",
166
-    "university students, but not e.g. primary school students."),
177
+    "university students, but not e.g. primary school students.")),
178
+  h4("The data"),
179
+  p("The 2018 New Zealand Census of Population and Dwellings",
180
+    a(href=paste0("https://cdm20045.contentdm.oclc.org/digital/",
181
+      "collection/p20045coll2/id/713/rec/3"), "asked"), 
182
+    "individuals for primary locations of employment and education ",
183
+    "and their usual method of transportation. Stats NZ has released",
184
+    a(href=
185
+"https://datafinder.stats.govt.nz/data/category/census/2018/commuter-view/",
186
+      "these data"),
187
+    "aggregated at the level of", 
188
+    a(href=paste0(
189
+"http://archive.stats.govt.nz/methods/classifications-and-standards/",
190
+"classification-related-stats-standards/geographic-areas/pg4.aspx#gsc.tab=0"),
191
+   "Statistical Area 2", .noWS = "after"), ". ",
192
+    "SA2 boundaries typically enclose areas with a population of a few ",
193
+    "thousand, corresponding approximately to urban suburbs and rural towns. ",
194
+    "The shapes of these areas have been heavily simplified in this map ",
195
+    "to reduce bandwidth and memory usage.",
196
+    a(href=
197
+"https://datafinder.stats.govt.nz/data/category/census/2018/commuter-view/",
198
+    "The original boundaries can be viewed and downloaded from the Stats NZ ",
199
+    "datafinder website.")),
167 200
   h4("Options"),
168 201
   p("The top right panel (toggleable via the blue switch) allows ",
169
-    "you to choose between visualising the people who commute from ",
202
+    "you to choose between the employment and education datasets, ",
203
+    "visualising the people who commute from ",
170 204
     "and to each area to both employment and education, and between ",
171 205
     "showing numbers of people or ",
172 206
     "their primary mode of transportation."),
@@ -180,8 +214,18 @@ again-data-visualisation-competition", "data visualisation competition",
180 214
   shiny::tags$ul(id="shortcutlist",
181 215
     shiny::tags$li(shiny::tags$kbd("I"), ": toggle this info page"),
182 216
     shiny::tags$li(shiny::tags$kbd("M"), ": focus map"),
183
-    shiny::tags$li(shiny::tags$kbd("P"), ": show employment"),
184
-    shiny::tags$li(shiny::tags$kbd("D"), ": show education"),
217
+    shiny::tags$ul(
218
+      shiny::tags$li(shiny::tags$kbd("+"), shiny::tags$kbd("-"),
219
+                     ": zoom map"),
220
+      shiny::tags$li(shiny::tags$kbd(HTML("&larr;")),
221
+                     shiny::tags$kbd(HTML("&uarr;")),
222
+                     shiny::tags$kbd(HTML("&rarr;")),
223
+                     shiny::tags$kbd(HTML("&darr;")),
224
+                     ": move map")
225
+    ),
226
+    shiny::tags$li(shiny::tags$kbd("S"), ": search map"),
227
+    shiny::tags$li(shiny::tags$kbd("P"), ": show employment data"),
228
+    shiny::tags$li(shiny::tags$kbd("D"), ": show education data"),
185 229
     shiny::tags$li(shiny::tags$kbd("F"), ": show people commuting from localities"),
186 230
     shiny::tags$li(shiny::tags$kbd("T"), ": show people commuting to localities"),
187 231
     shiny::tags$li(shiny::tags$kbd("O"), ": colour by most common commute type"),
@@ -213,6 +257,12 @@ again-data-visualisation-competition", "data visualisation competition",
213 257
     "total number of people to be large enough to escape censoring while ",
214 258
     "all transport", em("type"), "numbers are too small and so no most ",
215 259
     "common type can be determined."),
260
+  shiny::tags$blockquote("Does anyone commute to (or from?) the Chatham Islands?"),
261
+  p("No, but some people commute within it. Of 249 people commuting to ",
262
+    "employment, 105 travel by private car, 24 by company car, 18 walk, 12 ",
263
+    "are passengers in cars driven by other people, and 93 work at home. ",
264
+    "Of 84 people commuting to education, 39 take a schoolbus, 9 walk, 9 are ",
265
+    "passengers in a car, and 15 are educated at home."),
216 266
   div(class="scrollbuffer")
217 267
 )
218 268
 
@@ -260,6 +310,12 @@ $(function(){
260 310
       case 'M':
261 311
         document.getElementById('map').focus()
262 312
         break;
313
+      case 's':
314
+      case 'S':
315
+        var evObj = document.createEvent('Events');
316
+        evObj.initEvent('click', true, false);
317
+        document.getElementsByClassName('search-button')[0].dispatchEvent(evObj);
318
+        break;
263 319
       default:
264 320
         break;
265 321
     }