Skip to content

Commit a1c3800

Browse files
committed
added color module framework. lots of doc updates
1 parent 363af3b commit a1c3800

12 files changed

Lines changed: 494 additions & 149 deletions

‎NAMESPACE‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export(cruzTickMinor)
66
export(cruzTickStart)
77
export(cruzTickUpdate)
88
export(cruzplot_gui)
9+
export(mod_map_color_server)
10+
export(mod_map_color_ui)
911
export(mod_map_elements_server)
1012
export(mod_map_elements_ui)
1113
export(mod_map_range_server)
@@ -21,7 +23,11 @@ importFrom(dplyr,if_else)
2123
importFrom(geosphere,destPoint)
2224
importFrom(graphics,abline)
2325
importFrom(graphics,axis)
26+
importFrom(graphics,lines)
2427
importFrom(graphics,par)
28+
importFrom(graphics,rect)
29+
importFrom(graphics,text)
30+
importFrom(graphics,title)
2531
importFrom(maps,map)
2632
importFrom(shinydashboard,box)
2733
importFrom(shinydashboard,dashboardBody)
@@ -39,4 +45,6 @@ importFrom(shinyjs,useShinyjs)
3945
importFrom(stringr,str_detect)
4046
importFrom(stringr,str_sub)
4147
importFrom(stringr,str_to_upper)
48+
importFrom(utils,globalVariables)
4249
importFrom(utils,packageVersion)
50+
importFrom(utils,write.csv)

‎R/CruzPlot-package.R‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212
#' @import shiny
1313
#' @importFrom dplyr between case_when if_else
1414
#' @importFrom geosphere destPoint
15-
#' @importFrom graphics abline axis par
15+
#' @importFrom graphics abline axis par lines rect text title
1616
#' @importFrom maps map
1717
#' @importFrom shinydashboard box dashboardBody tabItems tabItem dashboardHeader
1818
#' dashboardPage dashboardSidebar sidebarMenu menuItem tabBox
1919
#' @importFrom shinyjs useShinyjs extendShinyjs js
2020
#' @importFrom stringr str_detect str_sub str_to_upper
21-
#' @importFrom utils packageVersion
21+
#' @importFrom utils globalVariables packageVersion write.csv
2222
#'
2323
"_PACKAGE"
24+
25+
# https://r-pkgs.org/package-within.html#echo-a-working-package
26+
utils::globalVariables("app_state_save")

‎R/cruzplot_gui.R‎

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ cruzplot_gui <- function(...) {
102102
title = "Map", width = 6, id = "tabset1",
103103
mod_map_range_ui("map_range"),
104104
mod_map_elements_ui("map_elements")[[1]],
105-
mod_map_elements_ui("map_elements")[[2]]
105+
mod_map_elements_ui("map_elements")[[2]],
106+
mod_map_color_ui("map_color")
106107
)
107108
)
108109
)
@@ -126,46 +127,28 @@ cruzplot_gui <- function(...) {
126127

127128

128129
#----------------------------------------------------------------------------
129-
# ### Create app state reactive
130-
# app_state <- reactiveValues(
131-
# # plot_height = NULL,
132-
# # lon.range = NULL,
133-
# # lat.range = NULL,
134-
# # world2 = NULL,
135-
# # map.name = list(),
136-
# # grid = NULL,
137-
# # grid_col = NULL,
138-
# # grid_lwd = NULL,
139-
# # grid_lty = NULL
140-
# )
141-
map_range <- map_elements <- reactiveValues()
142-
130+
### 'Initialize' reactives
131+
# map_range <- map_elements <- reactiveValues()
143132
load_state_map_range <- reactiveVal()
144133
load_state_map_elements <- reactiveVal()
134+
load_state_map_color <- reactiveVal()
145135

146-
# observeEvent(input$plot_height, {
147-
# app_state$plot_height <- input$plot_height
148-
# })
149136

150-
# # observe({ print(reactiveValuesToList(app_state)) })
151-
# output$current_state_display <- renderPrint({
152-
# reactiveValuesToList(app_state)
153-
# })
137+
#----------------------------------------------------------------------------
138+
### Map tab
139+
map.range.list <- mod_map_range_server("map_range", load_state_map_range, plot1.list$brush)
140+
map_range <- map.range.list[["map_range"]]
154141

142+
map_elements <- mod_map_elements_server("map_elements", load_state_map_elements, map_range)
143+
map_color <- mod_map_color_server("map_color", load_state_map_elements, map_range)
155144

156145
#----------------------------------------------------------------------------
157-
### Plot
146+
### Plots
158147
h <- reactive(input$plot_height)
159148
# plot_height <- reactive(input$plot_height)
160149
plot1.list <- mod_plot_server("plot1", h, map_range, map_elements)
161-
mod_plot_server("plot2", h, map_range, map_elements)
150+
mod_plot_server("plot2", h, map_range, map_elements, map_color)
162151

163-
#----------------------------------------------------------------------------
164-
### Map tab
165-
map.range.list <- mod_map_range_server("map_range", load_state_map_range, plot1.list$brush)
166-
map_range <- map.range.list[["map_range"]]
167-
168-
map_elements <- mod_map_elements_server("map_elements", load_state_map_elements, map_range)
169152

170153
#----------------------------------------------------------------------------
171154
### App 'environment' save/load
@@ -182,7 +165,8 @@ cruzplot_gui <- function(...) {
182165
app_state_save <- list(
183166
plot_height = input$plot_height,
184167
map_range = map.range.list$to_save(),
185-
map_elements = map_elements$to_save()
168+
map_elements = map_elements$to_save(),
169+
map_color = map_color$to_save()
186170
)
187171
incProgress(0.7)
188172
save(app_state_save, file = file)
@@ -225,13 +209,15 @@ cruzplot_gui <- function(...) {
225209
# 'reset' the reactiveVals, in case we're loading the same file
226210
load_state_map_range(NULL)
227211
load_state_map_elements(NULL)
212+
load_state_map_color(NULL)
228213

229214
load_state_map_range(app_state_save[["map_range"]])
230215
load_state_map_elements(app_state_save[["map_elements"]])
216+
load_state_map_color(app_state_save[["map_color"]])
231217
incProgress(0.35)
232218

233219
# Update widgets on the main page, not in a module
234-
updateNumericInput(session, "plot_height", value = app_state_save$plot_height)
220+
updateNumericInput(session, "plot_height", value = app_state_save[["plot_height"]])
235221
incProgress(0.05)
236222
})
237223

0 commit comments

Comments
 (0)