Skip to content

Commit

Permalink
fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
sheridar committed Nov 20, 2023
1 parent 6817157 commit b465e83
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 151 deletions.
16 changes: 8 additions & 8 deletions R/a-legend-draw.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ draw_key_point_trace <- function(data, params, size) {
0.5, 0.5,
pch = data$trace_shape,
gp = grid::gpar(
col = alpha(data$colour, 1),
col = ggplot2::alpha(data$colour, 1),
lty = data$linetype,
fontsize = data$trace_fontsize,
lwd = data$trace_lwd
Expand All @@ -64,9 +64,9 @@ draw_key_point_trace <- function(data, params, size) {
0.5, 0.5,
pch = data$shape,
gp = grid::gpar(
col = alpha(data$fill, data$alpha),
fontsize = data$size * .pt + pt_stroke * .stroke / 2,
lwd = pt_stroke * .stroke / 2
col = ggplot2::alpha(data$fill, data$alpha),
fontsize = data$size * ggplot2::.pt + pt_stroke * ggplot2::.stroke / 2,
lwd = pt_stroke * ggplot2::.stroke / 2
)
)

Expand All @@ -91,8 +91,8 @@ draw_key_path_trace <- function(data, params, size) {
0.1, 0.5, 0.9, 0.5,

gp = grid::gpar(
col = alpha(data$colour, 1),
lwd = data$size * .pt + data$stroke * .pt * 2,
col = ggplot2::alpha(data$colour, 1),
lwd = data$size * ggplot2::.pt + data$stroke * ggplot2::.pt * 2,
lty = 1,
lineend = "butt"
),
Expand All @@ -105,8 +105,8 @@ draw_key_path_trace <- function(data, params, size) {
0.1, 0.5, 0.9, 0.5,

gp = grid::gpar(
col = alpha(data$fill, 1),
lwd = data$size * .pt,
col = ggplot2::alpha(data$fill, 1),
lwd = data$size * ggplot2::.pt,
lty = data$linetype,
lineend = "butt"
),
Expand Down
26 changes: 13 additions & 13 deletions R/geom-path-trace.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ extra_bkgd_params <- paste0("bkgd_", c(
#' @return ggproto object
#' @seealso \link[ggplot2]{GeomPath}
#' @export
GeomPathTrace <- ggproto(
GeomPathTrace <- ggplot2::ggproto(
"GeomPathTrace", ggplot2::Geom,

required_aes = c("x", "y"),
Expand Down Expand Up @@ -347,7 +347,7 @@ GeomPathTrace <- ggproto(

# Munch data
# this divides data into line segments to plot
munched <- coord_munch(coord, data, panel_params)
munched <- ggplot2::coord_munch(coord, data, panel_params)

# Silently drop lines with less than two points, preserving order
rows <- stats::ave(seq_len(nrow(munched)), munched$group, FUN = length)
Expand Down Expand Up @@ -401,9 +401,9 @@ GeomPathTrace <- ggproto(
arrow = arrow,

gp = grid::gpar(
col = alpha(clr, munched$alpha)[!end],
fill = alpha(clr, munched$alpha)[!end], # modifies arrow fill
lwd = munched$size[!end] * .pt + strk * .pt * 2,
col = ggplot2::alpha(clr, munched$alpha)[!end],
fill = ggplot2::alpha(clr, munched$alpha)[!end], # modifies arrow fill
lwd = munched$size[!end] * ggplot2::.pt + strk * ggplot2::.pt * 2,
lty = lty,
lineend = lineend,
linejoin = linejoin,
Expand Down Expand Up @@ -441,9 +441,9 @@ GeomPathTrace <- ggproto(
arrow = arrow,

gp = grid::gpar(
col = alpha(clr, munched$alpha)[start],
fill = alpha(clr, munched$alpha)[start], # modifies arrow fill
lwd = munched$size[start] * .pt + strk * .pt * 2,
col = ggplot2::alpha(clr, munched$alpha)[start],
fill = ggplot2::alpha(clr, munched$alpha)[start], # modifies arrow fill
lwd = munched$size[start] * ggplot2::.pt + strk * ggplot2::.pt * 2,
lty = lty,
lineend = lineend,
linejoin = linejoin,
Expand Down Expand Up @@ -528,13 +528,13 @@ geom_line_trace <- function(mapping = NULL, data = NULL, stat = "identity",
#' @format NULL
#' @usage NULL
#' @export
GeomLineTrace <- ggproto(
GeomLineTrace <- ggplot2::ggproto(
"GeomLineTrace", GeomPathTrace,

extra_params = c(GeomPathTrace$extra_params, "na.rm", "orientation"),

setup_params = function(data, params) {
params$flipped_aes <- has_flipped_aes(data, params, ambiguous = TRUE)
params$flipped_aes <- ggplot2::has_flipped_aes(data, params, ambiguous = TRUE)

params
},
Expand All @@ -545,9 +545,9 @@ GeomLineTrace <- ggproto(
data <- data[order(data$PANEL, data$group, data$x), ]
data <- GeomPathTrace$setup_data(data, params)

data <- flip_data(data, params$flipped_aes)
data <- ggplot2::flip_data(data, params$flipped_aes)
data <- data[order(data$PANEL, data$group, data$x), ]
data <- flip_data(data, params$flipped_aes)
data <- ggplot2::flip_data(data, params$flipped_aes)

data
}
Expand Down Expand Up @@ -595,7 +595,7 @@ geom_step_trace <- function(mapping = NULL, data = NULL, stat = "identity",
#' @format NULL
#' @usage NULL
#' @export
GeomStepTrace <- ggproto(
GeomStepTrace <- ggplot2::ggproto(
"GeomStepTrace", GeomPathTrace,

draw_group = function(data, panel_params, coord, direction = "hv") {
Expand Down
20 changes: 10 additions & 10 deletions R/geom-point-trace.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ create_trace_layers <- function(mapping, data, stat, geom, position,
bkgd_params[names(background_params)] <- background_params
}

bkgd_lyr <- layer(
bkgd_lyr <- ggplot2::layer(
data = bkgd_data,
mapping = mapping,
stat = stat,
Expand All @@ -178,7 +178,7 @@ create_trace_layers <- function(mapping, data, stat, geom, position,
}

# Create trace layer
trace_lyr <- layer(
trace_lyr <- ggplot2::layer(
data = data,
mapping = mapping,
stat = stat,
Expand Down Expand Up @@ -253,7 +253,7 @@ GeomPointTrace <- ggplot2::ggproto(
pch = coords$trace_shape,

gp = grid::gpar(
col = alpha(coords$colour, 1),
col = ggplot2::alpha(coords$colour, 1),
lty = coords$linetype,
fontsize = coords$trace_fontsize,
lwd = coords$trace_lwd
Expand All @@ -267,9 +267,9 @@ GeomPointTrace <- ggplot2::ggproto(
pch = coords$shape,

gp = grid::gpar(
col = alpha(coords$fill, coords$alpha),
fontsize = coords$size * .pt + pt_stroke * .stroke / 2,
lwd = pt_stroke * .stroke / 2
col = ggplot2::alpha(coords$fill, coords$alpha),
fontsize = coords$size * ggplot2::.pt + pt_stroke * ggplot2::.stroke / 2,
lwd = pt_stroke * ggplot2::.stroke / 2
)
)

Expand Down Expand Up @@ -384,14 +384,14 @@ calculate_trace_size <- function(data) {
pch <- data$shape

# Calculate fontsize for closed shapes
fontsize <- data$size * .pt + pt_stroke * .stroke / 2
fontsize <- data$size * ggplot2::.pt + pt_stroke * ggplot2::.stroke / 2

fontsize[!pch %in% pch_open] <- fontsize[!pch %in% pch_open] + data$stroke * .stroke / 2
fontsize[!pch %in% pch_open] <- fontsize[!pch %in% pch_open] + data$stroke * ggplot2::.stroke / 2

# Calculate lwd for open shapes
lwd <- data$stroke * .stroke / 2
lwd <- data$stroke * ggplot2::.stroke / 2

lwd[pch %in% pch_open] <- lwd[pch %in% pch_open] * 2 + (pt_stroke * .stroke / 2)
lwd[pch %in% pch_open] <- lwd[pch %in% pch_open] * 2 + (pt_stroke * ggplot2::.stroke / 2)

# Add results to data
data$trace_fontsize <- fontsize
Expand Down
1 change: 1 addition & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
library(testthat)
library(vdiffr)
library(ggtrace)
library(ggplot2)

test_check("ggtrace")
Loading

0 comments on commit b465e83

Please sign in to comment.