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
   useShinyjs(),
48
   useShinyjs(),
49
   leafletjs,
49
   leafletjs,
50
   keyboardjs,
50
   keyboardjs,
51
+  shiny::tags$title("How did Kiwis commute in 2018?"),
51
   tags$style(type = "text/css", extracss),
52
   tags$style(type = "text/css", extracss),
52
   
53
   
53
   leafletOutput("map"),
54
   leafletOutput("map"),
65
                              inline = TRUE),
66
                              inline = TRUE),
66
                 radioButtons("radioinout", label="Show commuters who",
67
                 radioButtons("radioinout", label="Show commuters who",
67
                              choiceNames = list(
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
                              choiceValues = list(
71
                              choiceValues = list(
71
                                "res",
72
                                "res",
72
                                "work"
73
                                "work"
75
                 radioButtons("radiocolour",
76
                 radioButtons("radiocolour",
76
                              label = "Colour by",
77
                              label = "Colour by",
77
                              choiceNames = list(
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
                              choiceValues = list(
82
                              choiceValues = list(
82
                                "type",
83
                                "type",

+ 65
- 9
viz/extras.R View File

96
   left:0;
96
   left:0;
97
   bottom:5px;
97
   bottom:5px;
98
   right:0;
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
 #infobuttoncontainer label {
101
 #infobuttoncontainer label {
103
   font-weight: bold;
102
   font-weight: bold;
123
   columns: 20em 2;
122
   columns: 20em 2;
124
 }
123
 }
125
 kbd {
124
 kbd {
126
-  color: #444;
125
+  color: black;
127
   background-color: #eee;
126
   background-color: #eee;
128
   border-radius: 4px;
127
   border-radius: 4px;
129
-  padding: 0px 2px;
128
+  padding: 1px 6px;
130
   border-color: #444;
129
   border-color: #444;
131
   border-width: 1px;
130
   border-width: 1px;
132
   -webkit-box-shadow: 1px 1px #444;
131
   -webkit-box-shadow: 1px 1px #444;
133
   box-shadow: 1px 1px #444;
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
     a(href=
169
     a(href=
160
 "https://www.stats.govt.nz/2018-census/there-and-back-
170
 "https://www.stats.govt.nz/2018-census/there-and-back-
161
 again-data-visualisation-competition", "data visualisation competition",
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
     "older who gave an employment location in the 2018 census, while the ",
174
     "older who gave an employment location in the 2018 census, while the ",
164
     "education data counts people in education 15 years or older who gave an ",
175
     "education data counts people in education 15 years or older who gave an ",
165
     "education location in the 2018 census—including older highschoolers and ",
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
   h4("Options"),
200
   h4("Options"),
168
   p("The top right panel (toggleable via the blue switch) allows ",
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
     "and to each area to both employment and education, and between ",
204
     "and to each area to both employment and education, and between ",
171
     "showing numbers of people or ",
205
     "showing numbers of people or ",
172
     "their primary mode of transportation."),
206
     "their primary mode of transportation."),
180
   shiny::tags$ul(id="shortcutlist",
214
   shiny::tags$ul(id="shortcutlist",
181
     shiny::tags$li(shiny::tags$kbd("I"), ": toggle this info page"),
215
     shiny::tags$li(shiny::tags$kbd("I"), ": toggle this info page"),
182
     shiny::tags$li(shiny::tags$kbd("M"), ": focus map"),
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
     shiny::tags$li(shiny::tags$kbd("F"), ": show people commuting from localities"),
229
     shiny::tags$li(shiny::tags$kbd("F"), ": show people commuting from localities"),
186
     shiny::tags$li(shiny::tags$kbd("T"), ": show people commuting to localities"),
230
     shiny::tags$li(shiny::tags$kbd("T"), ": show people commuting to localities"),
187
     shiny::tags$li(shiny::tags$kbd("O"), ": colour by most common commute type"),
231
     shiny::tags$li(shiny::tags$kbd("O"), ": colour by most common commute type"),
213
     "total number of people to be large enough to escape censoring while ",
257
     "total number of people to be large enough to escape censoring while ",
214
     "all transport", em("type"), "numbers are too small and so no most ",
258
     "all transport", em("type"), "numbers are too small and so no most ",
215
     "common type can be determined."),
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
   div(class="scrollbuffer")
266
   div(class="scrollbuffer")
217
 )
267
 )
218
 
268
 
260
       case 'M':
310
       case 'M':
261
         document.getElementById('map').focus()
311
         document.getElementById('map').focus()
262
         break;
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
       default:
319
       default:
264
         break;
320
         break;
265
     }
321
     }