forked from npct/pct-shiny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui-base.R
160 lines (151 loc) · 6.61 KB
/
ui-base.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# This is UI base that runs on every connected client
#
# Copyright (C) 2016 Nikolai Berkoff, Ali Abbas and Robin Lovelace
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
library(shiny)
library(leaflet)
scenarios <- c("Census 2011 Cycling" = "olc",
"Government Target" = "govtarget",
"Gender equality" = "gendereq",
"Go Dutch" = "dutch",
"Ebikes (prototype)" = "ebike")
line_types <- c("None" = "none",
"Straight Lines" = "straight",
"Fast Routes" = "d_route",
"Fast & Quiet Routes" = "route",
"Route Network" = "rnet")
attrsZone <- c("Scenario Level of Cycling (SLC)" = "slc",
"Scenario Increase in Cycling (SIC)" = "sic")
map_base_attrs <- c("Roadmap" = "roadmap",
"Satellite" = "satellite",
"IMD" = "IMD")
shinyUI(
navbarPage(
title = "National Propensity to Cycle Tool (Prototype)",
id="nav",
tabPanel(
"Interactive map",
div(
class="outer",
tags$head(
includeScript("assets/google-analytics.js"),
includeScript("assets/extra.js"),
includeCSS("www/stylesheet.css")
),
br(),
leafletOutput("map", width="100%", height="95%"),
absolutePanel(
id = "controls", class = "panel panel-default",
fixed = TRUE, top = 110, right = 20, width = 180,
height = "auto", style = "opacity: 0.9",
tags$div(title="Show/Hide Panel",
a(id = "togglePanel", style="font-size: 80%", span(class="glyphicon glyphicon-circle-arrow-up", "Hide"))
),
div(
id = "input_panel",
tags$div(title="Scenario details can be seen in the Help tab",
selectInput("scenario", "Scenario:", scenarios, selectize = F)
),
tags$div(title="Shows the cycling flow between the centres of zones",
selectInput("line_type", "Cycling Flows", line_types, selected = "none", selectize = F)
),
conditionalPanel(
condition = "input.line_type != 'none'",
tags$div(title="Untick to allow lines to update when you move the map",
checkboxInput("freeze", "Freeze Lines", value = TRUE)
),
tags$div(title="Flows to show",
sliderInput("nos_lines", label = "Number of Lines", 1, 100, value = 10)
)
),
tags$div(title="Change base of the map",
tags$div(class = "rbox",
radioButtons("map_base", "Map Base:", map_base_attrs)
)
),
conditionalPanel(
condition = "input.line_type != 'none'",
tags$div(downloadButton('downloadData', 'geojson'))
)
)
),
absolutePanel(
cursor = "default", id = "legend", class = "panel panel-default",
top = 100, left = 25, height = 30, width = 100,
style = "opacity: 0.7",
tags$div(title="Show/Hide zone legend",
a(id = "toggleLegend", style="font-size: 80%", span(class="glyphicon glyphicon-circle-arrow-up", "Hide"))
),
div(id = "zone_legend",
tags$div(title="Scenario-specific quartiles of cycling level",
selectInput("triptype", label = "Trip data", choices = c("Commuting", "Education (unavailable)", "Shopping (unavailable)"), selected = "Commute data", selectize = F),
conditionalPanel(
condition = "input.map_base != 'c'",
plotOutput("legendCyclingPotential", width = "100%", height = 300)
)
)
)
),
conditionalPanel(
condition = "input.map_base == 'IMD'",
absolutePanel(
cursor = "default", id = "legend", class = "panel panel-default",
bottom = 200, right = 5, height = 20, width = 215,
style = "opacity: 0.7",
tags$div(title="Show/Hide map legend",
a(id = "toggleMapLegend", style="font-size: 80%", span(class="glyphicon glyphicon-circle-arrow-up", "Hide"))
),
div(id = "map_legend",
tags$div(title="Index of Multiple Deprivation",
plotOutput("IMDLegend", width = "100%", height = 180)
)
)
)
),
tags$div(id="cite",
'This is a prototype released under the', a('GNU AGP licence', href= "licence.html", target='_blank'), 'and funded by the', a('DfT', href = "https://www.gov.uk/government/organisations/department-for-transport", target="_blank")
)
)
),
tabPanel("Lines Data",
br(),
br(),
helpText("This tab shows the underlying data of the Cycling Flows (straight or otherwise)"),
uiOutput("warningMessage"),
DT::dataTableOutput("linesDatatable")
),
tabPanel("Zones Data",
br(),
br(),
helpText(HTML("This tab shows the underlying data of the Zones </br>
<strong>Data Source: </strong> We are using the 2011 Census data for England and Wales.
It contains origin-destination data on workplace flows. For more information, please see the
<a target='_blank' href = \"https://www.nomisweb.co.uk/census/2011/wu03ew\">source</a>")),
DT::dataTableOutput("zonesDataTable")
),
tabPanel("Model Output",
htmlOutput("moutput")
),
tabPanel("About",
includeHTML(file.path("static", "more-info.html"))
),
tabPanel("How to use it",
includeMarkdown(file.path("static", "helpmd.md"))
),
tabPanel("FAQs",
includeHTML(file.path("static", "FAQs.html"))
)
)
)