Skip to content

Commit

Permalink
fix scoping for custom key_glyph and change legend order in show_hmpr…
Browse files Browse the repository at this point in the history
…eport
  • Loading branch information
fawda123 committed Jun 10, 2024
1 parent 5eb2368 commit e610877
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion R/globalVariables.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions R/show_hmpreport.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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"),
Expand All @@ -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,
Expand Down

0 comments on commit e610877

Please sign in to comment.