-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathui.R
141 lines (122 loc) · 4.85 KB
/
ui.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
library("dplyr")
library("DT")
library("shiny")
library("leaflet")
shinyUI(navbarPage("Blackspot", id="nav", collapsible=T,
tabPanel("Map",
div(class="outer",
tags$head(
includeScript("analytics.js"),
tags$link(rel = "stylesheet", type = "text/css",
href = "ion.rangeSlider.skinFlat.css"),
includeScript("spin.min.js"),
includeCSS("styles.css")
),
leafletOutput("mymap", width="100%", height="100%"),
tags$script("
var spinner = new Spinner().spin();
$( 'div#mymap' ).append(spinner.el);"),
absolutePanel(id = "controls", class = "panel panel-default", fixed = TRUE,
draggable = TRUE, top = 100, left = "auto", right = 20, bottom = "auto",
width = 360, height = "auto",
h2(),
p(class="intro",
strong("Blackspot"), " shows vechicle collisions in",
"the city of Edinburgh, UK. Data from",
a("Edinburgh Open Data.",
href="http://www.edinburghopendata.info/dataset/vehicle-collisions",
target="_blank")),
tabsetPanel(
tabPanel("Controls",
dateRangeInput('dates',
label = 'Occurred between:',
start = as.Date("2010-01-01"), end = as.Date("2013-07-01")),
selectInput("color", "Colour by:",
choices=c("None", "Severity", "Casualties", "Time", "Vehicles", "Speed limit")),
sliderInput("alpha", label="Opacity:",
min=0, max=1, value=0.4, step=.025, ticks=T),
fluidRow(
column(6,
sliderInput("base", label="Point size:",
min=1, max=5, value=1)
),
column(6,
selectInput("scale", label="Scale by:", width=120,
selected="Vehicles",
choices=c("Casualties", "Vehicles"))#)
)
),
hr(class="thin"),
p("Under development by",
a("@benjaminlmoore", href="http://twitter.com/benjaminlmoore",
target="_blank"),
HTML("•"), "See the code on ",
a("github", href="http://github.com/blmoore/blackspot",
target="_blank"),
class="foot")
),
tabPanel("Graphs",
#p("Static plots"),
plotOutput("monthTotals", height = "110px"),
plotOutput("month_waffle", height = "120px"),
#hr(),
plotOutput("involving", height = "120px", width="100%"),
hr(class="thin")
),
tabPanel("About",
p(class="topp", "Explore vehicle collisions recorded in Edinburgh",
"between 2010 and 2013 in this interactive data visualisation."
),
p("Blackspot is written in ",
a("Shiny,", href="http://shiny.rstudio.com/", target="_blank"),
"a web application framework for the R language.",
"Maps are built with ",
a("leaflet.js", href="http://leafletjs.com/", target="_blank"),
"via the",
a("R language bindings,", href="https://rstudio.github.io/leaflet/",
target="_blank"),
"and using map data from",
a("Open Street Map.", href="http://www.openstreetmap.org/copyright",
target="_blank")
),
p("Project under development by ",
a("@benjaminlmoore", href="http://twitter.com/benjaminlmoore",
target="_blank"),
HTML("—"),
"see the full code on ",
a("github", href="http://github.com/blmoore/blackspot",
target="_blank"),
"or run locally with:"
),
pre("shiny::runGitHub('blmoore/blackspot')"),
hr(class="thin")
)
# end about panel
),
tags$script('
Shiny.addCustomMessageHandler("map_done",
function(s) {
spinner.stop();
$( "div#mymap" ).remove(spinner);
});')
),
# mobile panel
div(class="mobile-panel",
p(strong("Blackspot"), " shows vechicle collisions in",
"the city of Edinburgh, UK. Written in R Shiny by",
a("@benjaminlmoore,", href="https://twitter.com/benjaminlmoore"),
"see the code on ",
a("github.", href="http://github.com/blmoore/blackspot"),
"Data: ",
a("Edinburgh Open Data.",
href="http://www.edinburghopendata.info/dataset/vehicle-collisions")),
hr(class="thin"),
radioButtons("color_mob", "Colour by:", inline=T,
choices=c("None", "Severity", "Casualties", "Time", "Vehicles", "Speed limit"))
)
# tags$div(id="cite",
# a("@benjaminlmoore", href="http://twitter.com/benjaminlmoore"))
)
), tabPanel("Table", DT::dataTableOutput("table"))
)
)