@@ -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