Skip to content

Commit

Permalink
add yaxis scaling to plots
Browse files Browse the repository at this point in the history
  • Loading branch information
ibidyouadu committed Aug 12, 2021
1 parent d7f65c8 commit 158824f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions R/mod_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ plotServer <- function(id, rv){
data_filtered <- rv$data_filtered
sel_family <- rv$sel_family
sel_maa <- rv$sel_maa
y_scale <- rv$sel_yscale

if (is.null(sel_maa)) {
div(class="warning_message", "No managed access area selected.")
Expand All @@ -35,6 +36,7 @@ plotServer <- function(id, rv){
"Fish Diversity" = plot_diversity(data_filtered, sel_family),
"Fish Size" = plot_size(data_filtered, sel_family)
)
p$facet$params$free$y <- y_scale
output$plot <- renderPlot(p)
plotOutput(ns('plot'))
}
Expand Down
14 changes: 8 additions & 6 deletions R/mod_side_display.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ sidebarDisplayServer <- function(id, rv){
'Plot Type',
choices = c('Bar plots', 'Range plots')
),
radioButtons(ns('sel_yaxis'),
radioButtons(ns('sel_yscale'),
'Y-axis',
choices = c('Free', 'Fixed')
choices = c('Free'=TRUE,
'Fixed'=FALSE),
selected = TRUE
),
pickerInput(ns('sel_family'),
'Fish family',
Expand Down Expand Up @@ -104,6 +106,10 @@ sidebarDisplayServer <- function(id, rv){
)
}, ignoreInit = TRUE)

observeEvent(input$sel_yscale, {
rv$sel_yscale <- as.logical(input$sel_yscale)
})

observeEvent(input$sel_family, {
rv$sel_family <- input$sel_family
# rv$data_filtered <- rv$data_full %>%
Expand All @@ -115,10 +121,6 @@ sidebarDisplayServer <- function(id, rv){
# rv$data_map <- get_biomass_loc(rv$data_aggreg)
}, ignoreInit = TRUE
)

observeEvent(input$sel_metric, {
rv$sel_metric <- input$sel_metric
}, ignoreInit = TRUE)
}) # modServer
} # server

Expand Down
1 change: 1 addition & 0 deletions R/rv.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ initialize_rv <- function(INIT) {
current_tab = INIT$CURRENT_TAB,
sel_country = INIT$SEL_COUNTRY,
sel_metric = INIT$SEL_METRIC,
sel_yscale = INIT$SEL_YSCALE,
sel_family = INIT$SEL_FAMILY,
basemap = INIT$BASEMAP,
# there is a fish family that is blank. currently, selecting that will crash
Expand Down
9 changes: 7 additions & 2 deletions R/utils_init.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# INIT <- list()
# INIT$CURRENT_TAB <- 'Coral Reefs'
# INIT$SEL_METRIC <- 'Fish Biomass'
# INIT$SEL_YSCALE <- TRUE
# INIT$COUNTRY_CHOICES <- c("Honduras" = "HND",
# "Indonesia" = "IDN",
# "Mozambique" = "MOZ",
Expand All @@ -27,5 +28,9 @@
# INIT$COORDS <- aggregate(cbind(lon, lat) ~ location_name,
# data=INIT$DATA_FULL, FUN=mean)
# usethis::use_data(INIT, overwrite=TRUE)
# devtools::document()

#
#
# note: do not put devtools::document here and think you can update init, usethis::use_data,
# and devtools::document all in one go.... because devtools::document is in this file, it will
# go in an infinite loop, continuously running devtools::document. Only use devtools::document
# in the console !
Binary file modified data/INIT.rda
Binary file not shown.

0 comments on commit 158824f

Please sign in to comment.