From e6108778e33f1823088a4eb68f3cf016ad28084d Mon Sep 17 00:00:00 2001 From: fawda123 Date: Mon, 10 Jun 2024 10:30:01 -0400 Subject: [PATCH] fix scoping for custom key_glyph and change legend order in show_hmpreport --- R/globalVariables.R | 2 +- R/show_hmpreport.R | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/globalVariables.R b/R/globalVariables.R index e2d24305..c3dc51d0 100644 --- a/R/globalVariables.R +++ b/R/globalVariables.R @@ -70,7 +70,7 @@ globalVariables(c("Chlorophyll_aQ", "Latitude", "Longitude", "SampleTime", "Samp "sumgt400", "yearfac", "nyrs", "ActivityDepthHeightMeasure.MeasureUnitCode", "ActivityDepthHeightMeasure.MeasureValue", "chla_target", "chla_val", "la_target", "la_val", "MonitoringLocationTypeName", "loadest", "out1", - "v", "z", "<<-")) + "v", "z")) #' @importFrom grDevices rgb NULL diff --git a/R/show_hmpreport.R b/R/show_hmpreport.R index c6faf573..c193ff5d 100644 --- a/R/show_hmpreport.R +++ b/R/show_hmpreport.R @@ -257,7 +257,7 @@ show_hmpreport <- function(acres, subtacres, hmptrgs, typ, twocol = FALSE, strat ) # legend drawing function up arrow - draw_key_up <<- function(data, params, size){ + draw_key_up <- function(data, params, size){ params$arrow$length <- grid::unit(0.35, 'cm') grid::segmentsGrob(0.1, 0.1, 0.9, 0.9, gp = grid::gpar(col = 'black', fill = 'black', lwd = 2, lineend = "butt"), @@ -266,7 +266,7 @@ show_hmpreport <- function(acres, subtacres, hmptrgs, typ, twocol = FALSE, strat } # legend drawing function down arrow - draw_key_down <<- function(data, params, size){ + draw_key_down <- function(data, params, size){ params$arrow$length <- grid::unit(0.35, 'cm') grid::segmentsGrob(0.1, 0.9, 0.9, 0.1, gp = grid::gpar(col = 'black', fill = 'black', lwd = 2, lineend = "butt"), @@ -287,18 +287,18 @@ show_hmpreport <- function(acres, subtacres, hmptrgs, typ, twocol = FALSE, strat geom_custom_up(data = toplo[toplo$shapv == 'Trending above', ], ggplot2::aes(x = metric, y = yearfac, color = fillv), show.legend = F) + geom_custom_down(data = toplo[toplo$shapv == 'Trending below', ], ggplot2::aes(x = metric, y = yearfac, color = fillv), show.legend = F) + ggplot2::scale_colour_manual(values = cols) + - ggplot2::guides(color = ggplot2::guide_legend(override.aes = list(alpha = 1, shape = 15, size = 6))) + + ggplot2::guides(color = ggplot2::guide_legend(override.aes = list(alpha = 1, shape = 15, size = 6), order = 1)) + ggplot2::geom_segment(data = toplo, ggplot2::aes(x = metric, xend = metric, y = yearfac, yend = yearfac, linetype = z), arrow = grid::arrow(length = grid::unit(0.25, 'cm'), type = 'open', angle = 45), size = 0.7, alpha = 0, - key_glyph = "up" + key_glyph = draw_key_up ) + ggplot2::geom_segment(data = toplo, ggplot2::aes(x = metric, xend = metric, y = yearfac, yend = yearfac, linetype = v), arrow = grid::arrow(length = grid::unit(0.25, 'cm'), type = 'open', angle = 45), size = 0.7, alpha = 0, - key_glyph = "down" + key_glyph = draw_key_down ) + labs( linetype = NULL,