-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathui.R
205 lines (173 loc) · 8.2 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#### load required libraries ####
if(!require(raster)){
install.packages("raster")
library(raster)
}
if(!require(shiny)){
install.packages("shiny")
library(shiny)
}
if(!require(RColorBrewer)){
install.packages("RColorBrewer")
library(RColorBrewer)
}
if(!require(malariaAtlas)){
install.packages("malariaAtlas")
library(malariaAtlas)
}
if(!require(shinydashboard)){
install.packages("shinydashboard")
library(shinydashboard)
}
if(!require(stringr)){
install.packages("stringr")
library(stringr)
}
if(!require(shinyalert)){
install.packages("shinyalert")
library(shinyalert)
}
if(!require(shinyBS)){
install.packages("shinyBS")
library(shinyBS)
}
if(!require(shinythemes)){
install.packages("shinythemes")
library(shinythemes)
}
if(!require(shinycssloaders)){
install.packages("shinycssloaders")
library(shinycssloaders)
}
if(!require(shinyjs)){
install.packages("shinyjs")
library(shinyjs)
}
if(!require(mapview)){
install.packages("mapview")
library(mapview)
}
if(!require(leaflet)){
install.packages("leaflet")
library(leaflet)
}
# generate a list of countries for which MAP data exists
# fix some encoding and country issues
load('data/sf_afr_simp_fao.rda')
sf_afr_simp <- sf_afr_simp[sf_afr_simp$COUNTRY_ID != "XXX",]
sf_afr_simp <- sf_afr_simp[sf_afr_simp$COUNTRY_ID != "MYT",]
sf_afr_simp$name[sf_afr_simp$GAUL_CODE == "16840"] <- "Goh-Djiboua"
sf_afr_simp$name[sf_afr_simp$GAUL_CODE == "818"] <- "Extreme-Nord"
country_names <- sf_afr_simp$name[sf_afr_simp$ADMN_LEVEL==0]
country_names <- country_names[country_names != "Hala'ib triangle"]
country_names <- country_names[country_names != "Ma'tan al-Sarra"]
country_names <- country_names[country_names != "Ilemi triangle"]
country_names <- country_names[country_names != "Abyei"]
country_names <- country_names[country_names != "Cape Verde"]
country_names <- country_names[country_names != "Djibouti"]
country_names <- country_names[country_names != "Seychelles"]
country_names <- sort(country_names)
country_names[7] <- "Cote d'Ivoire"
# define a UI use a fluid bootstrap layout
appCSS <- "
#loading-content {
position: absolute;
background: #344151;
opacity: 1;
z-index: 100;
left: 0;
right: 0;
height: 100%;
text-align: center;
color: #FFFFFF;
}
"
navbarPage(
"MaDD - Malaria Data by District",
tabPanel("Application",
fluidPage(theme = shinytheme("flatly"),
useShinyalert(),
useShinyalert(),
useShinyjs(),
inlineCSS(appCSS),
# Loading message
div(
id = "loading-content",
h2("Loading Application...")
),
hidden(
div(
id = "app-content",
p(" ")
)
),
# set a margin for the checkbox
tags$head(
tags$style(
HTML(".checkbox-inline {
margin-left: 0px;
margin-right: 10px;}
.checkbox-inline+.checkbox-inline {
margin-left: 0px;
margin-right: 10px;
}"))),
# create a sidebar where the user can select a country, and districts (etc.)
# we may change this to a header once basic functionality is resolved
sidebarLayout(
# sidebar panel for the inputs
sidebarPanel(
uiOutput("tab"),
br(),
"More information can be found in the help tab.",
br(),
br(),
# country selection (only one country allowed at a time)
selectInput("country", "Country :",
choices = country_names,
selected = "Benin"),
# hover-over tooltip
bsTooltip(id = "country",
title = "Please select the country of interest, available districts will update based on this selection.",
placement = "right", trigger = "hover", options = list(container = "body")),
# choose raster layers
checkboxGroupInput("selected_raster", "Data to show and compare :",
choices = list("Malaria in children (Falciparum)" = "Plasmodium falciparum PR2 10",
"Malaria incidence (Falciparum)" = "Plasmodium falciparum Incidence",
"Insecticide Treated Net distribution" = "Insecticide treated bednet ITN coverage",
"Travel time to nearest city" = "A global map of travel time to cities to assess inequalities in accessibility in 2015"),
selected = "Plasmodium falciparum PR2 10"),
helpText("First layer is shown in map, other layers included in 'Output'"),
# dynamic district selection
uiOutput("select_dist"),
# hover-over tooltip
bsTooltip(id = "select_dist",
title = "Please select the districts to feature within the comparison/ranking.",
placement = "right", trigger = "hover", options = list(container = "body")),
# button to generate stats
actionButton(inputId = "processStats", label = "Generate Report", class='butt'),
tags$head(tags$style(".butt{margin-bottom:5px;}")),
# hover-over tooltip
bsTooltip(id = "processStats",
title = "Run generation of statistics and ranking system. This will produce results which feature in the tabs to the right.",
placement = "right", trigger = "hover", options = list(container = "body")),
# download report button (defined in server)
uiOutput("downloadbutton")
),
mainPanel(
tabsetPanel(id='main0', type = "tabs",
#tabPanel(value ='tab1', title = "Selected country and districts", div(style = 'overflow-y:scroll;height:750px;',plotOutput("select_country", height = '750px', width = '750px'))),
tabPanel(value ='tab1', title = "Map", div(style = 'overflow-y:scroll;height:750px;',leafletOutput("mapview_country_raster", height = '750px', width = '750px'))),
#tabPanel(value ='tab1', title = "Map", leafletOutput("mapview_country_raster")),
tabPanel(value ='tab3', title = "Table", DT::dataTableOutput("activetable")),
tabPanel(value ='tab2', title = "Output Report", div(style = 'overflow-y:scroll;height:750px;',htmlOutput("report"))))
) # end of main panel
) # end of fluid page # end of sidebar layout
)
), # end of tab panel
# help main panel
tabPanel("Help",
# sub-panels within the 'help' tab
tabsetPanel(type = 'tabs',
tabPanel(title='Help', includeMarkdown('help.md')),
tabPanel(title='About', includeMarkdown('about.md'))))
)