Skip to content

Commit 53e6fab

Browse files
committed
introduce custom settings to increase max.n.points
1 parent 6513edc commit 53e6fab

6 files changed

Lines changed: 96 additions & 21 deletions

File tree

global.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
###StaMPS-Visualizer global script###
33
#####################################
44

5+
###################
6+
###load settings###
7+
###################
8+
9+
settings <- readRDS("settings.RData")
10+
511
####################
612
###Visualizer Map###
713
####################

server.R

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,15 @@ library(lubridate)
88
library(rgdal)
99
library(data.table)
1010

11-
##################
12-
# prepare objects#
13-
##################
14-
15-
psts <- NULL
16-
17-
# max numbers of points to render by leaflet in the interactive map
18-
max.n.points <- 50000
11+
#################
12+
#prepare objects#
13+
#################
1914

2015
# prepare color ramp
2116
colramp <- rev(matlab.like(10))
2217

23-
# init stamps object
18+
# initialize empty objects
19+
psts <- NULL
2420
stamps <- NULL
2521

2622
####################
@@ -101,6 +97,41 @@ render.stamps <- function(pointsize = 5, setview = TRUE){
10197

10298
function(input, output, session) {
10399

100+
## Settings ##################################################
101+
# render start settings texts
102+
output$text.settings <- if(settings$defaultflag == TRUE){
103+
renderText({paste("Values were initially loaded from default settings")})}else{
104+
renderText({paste("Values were initially loaded from user settings")})}
105+
106+
output$text.max.n.points <- if(settings$defaultflag == TRUE){
107+
renderText({paste("Values are set to default: ", settings$max.n.points, sep = "")})}else{
108+
renderText({paste("Value is set by user: ", settings$max.n.points, sep = "")})}
109+
110+
# load default settings
111+
observeEvent(input$load.def.settings, {
112+
settings <<- list(default = settings$default,
113+
max.n.points = settings$default$max.n.points,
114+
defaultflag = settings$default$defaultflag)
115+
output$text.max.n.points <- renderText({paste("Values are set to default: ", settings$max.n.points, sep = "")})
116+
saveRDS(settings, "settings.RData")
117+
output$text.settings <- renderText({paste("Values were loaded from default settings")})
118+
})
119+
120+
# change max.n.points
121+
# change for current session
122+
observeEvent(input$set.max.n.points, {
123+
settings$max.n.points <<- input$select.max.n.points
124+
settings$defaultflag <<- FALSE
125+
output$text.max.n.points <- renderText({paste("Value is set by user: ", settings$max.n.points, sep = "")})
126+
})
127+
# change for current session and save to user settings session
128+
observeEvent(input$save.max.n.points, {
129+
settings$max.n.points <<- input$select.max.n.points
130+
settings$defaultflag <<- FALSE
131+
output$text.max.n.points <- renderText({paste("Value is set by user: ", settings$max.n.points, sep = "")})
132+
saveRDS(settings, "settings.RData")
133+
})
134+
104135
## Interactive Map ###########################################
105136
output$stusi <- renderUI({
106137
lapply(1, function(x) {
@@ -151,22 +182,21 @@ function(input, output, session) {
151182
}else{
152183
# check the numbers of lines
153184
n.points <- nrow(data.table::fread(paste("input/stusi/", input$stusi, ".csv", sep = ""), select = 1L))
154-
if(n.points <= max.n.points){
185+
if(n.points <= settings$max.n.points){
155186
stamps <<- load.stamps(input$stusi)
156187
render.stamps(pointsize = input$pcex)
157188
}else{
158189
shinyalert(title = "Number of max points exceeded",
159190
text = paste("You try to load ", n.points, " points where the max number of points is ",
160-
max.n.points, ". Continue to load all points might slow down and eventually crush the Visualizer. ",
161-
"Cancel to make a spatial subset or raise the number of maximum points. ",
162-
"For further instructions switch to the Manual tab.",
191+
settings$max.n.points, ". To raise the number of maximum points, go to Settings.",
163192
sep = ""),
164-
type = "input",
165-
inputType = "",
166-
showCancelButton = TRUE,
167-
showConfirmButton = TRUE,
168-
confirmButtonText = "Continue",
169-
inputId = "ex.max.n.point")
193+
type = "error"
194+
#inputType = "",
195+
#showCancelButton = TRUE,
196+
#showConfirmButton = TRUE,
197+
#confirmButtonText = "Continue",
198+
#inputId = "ex.max.n.point"
199+
)
170200
output$stusi <- renderUI({
171201
lapply(1, function(x) {
172202
selectInput("stusi", "Select case study", stusi,

settings.RData

129 Bytes
Binary file not shown.

ui.R

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ shinyUI(fluidPage(
4040
menuItem("Baseline Plot", tabName = "blplot", icon = icon("project-diagram")),
4141
#menuItem("Data Manager", tabName = "datman", icon = icon("folder-open")),
4242
#menuItem("Explanation", tabName = "expl", icon = icon("comment")),
43-
#menuItem("Settings", tabName = "settings", icon = icon("sliders-h")),
43+
menuItem("Settings", tabName = "settings", icon = icon("sliders-h")),
4444
menuItem("Manual", tabName = "manual", icon = icon("book-open")),
4545
#menuItem("Literature", tabName = "lit", icon = icon("book")),
4646
menuItem("Cite", tabName = "cite", icon = icon("graduation-cap"))
@@ -157,7 +157,38 @@ shinyUI(fluidPage(
157157
fluidRow(verbatimTextOutput("bl.text"))
158158
)
159159
)
160-
))
160+
)), # end baseline plot tab
161+
tabItem(tabName = "settings",
162+
includeMarkdown("www/settings.md"),
163+
fluidRow(
164+
column(2, actionButton("load.def.settings",
165+
label = "Load default settings"#,
166+
#icon = "archive"
167+
)),
168+
column(4, verbatimTextOutput("text.settings")),
169+
),
170+
includeMarkdown("www/settings_maxnpoints.md"),
171+
fluidRow(
172+
column(2, numericInput(inputId = "select.max.n.points",
173+
label = "max.n.points",
174+
value = settings$max.n.points,
175+
min = 1,
176+
max = 500000,
177+
width = "200px")),
178+
column(2, actionButton("set.max.n.points",
179+
label = "Enable for current session",
180+
style = "margin-top: 25px;"
181+
#icon = "cogs"
182+
)),
183+
column(2, actionButton("save.max.n.points",
184+
label = "Save to user settings",
185+
style = "margin-top: 25px;"
186+
#icon = "user-cog"
187+
)),
188+
column(3, verbatimTextOutput("text.max.n.points"),
189+
style = "margin-top: 25px;")
190+
)
191+
) # end setting tab
161192
) # end body items
162193
) # end dashboard body
163194
) # end dashboard page

www/settings.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Settings
2+
3+
## Load default settings

www/settings_maxnpoints.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Maximum Number of Points
2+
3+
```max.n.points``` is the maximum number of points, rendered by leaflet.
4+
The default setting is 50,000.
5+
Higher values might slow down the Visualizer especially during loading new data or even crash the application, depending on your hardware.

0 commit comments

Comments
 (0)