Skip to content

Commit ba53a46

Browse files
committed
with() errors when supplied with a NULL value
1 parent d1b3348 commit ba53a46

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

R/ggplotly.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,11 @@ gg2list <- function(p, width = NULL, height = NULL,
624624
d <- expand(rng$graticule)
625625
d$x <- scales::rescale(d$x, rng$x_range, from = c(0, 1))
626626
d$y <- scales::rescale(d$y, rng$y_range, from = c(0, 1))
627-
params <- with(panelGrid, list(colour = colour, size = size, linetype = linetype))
627+
params <- list(
628+
colour = panelGrid$colour,
629+
size = panelGrid$size,
630+
linetype = panelGrid$linetype
631+
)
628632
grill <- geom2trace.GeomPath(d, params)
629633
grill$hoverinfo <- "none"
630634
grill$showlegend <- FALSE

tests/testthat/test-ggplot-sf.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,17 @@ test_that("sf aspect ratio is correct", {
6969
expect_equivalent(l$layout$xaxis$scaleanchor, "y")
7070
expect_equal(l$layout$xaxis$scaleratio, 0.81678435872298)
7171
})
72+
73+
74+
test_that("works with a blank theme", {
75+
skip_if_not_installed("sf")
76+
77+
p <- ggplot(nc) + geom_sf() +
78+
ggthemes::theme_map()
79+
80+
l <- save_outputs(p, "sf-theme-map")
81+
82+
# TODO: perhaps the graticule shouldn't be included at all?
83+
expect_length(l$data, 2)
84+
expect_equivalent(l$data[[1]]$line$color, "transparent")
85+
})

0 commit comments

Comments
 (0)