Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3a33b1a

Browse filesBrowse files
authored
Make ribbon_dat() a no-op if there is no data (#2209)
* Close #2208: make ribbon_dat() a no-op if there is no data * Update news
1 parent a69ba8b commit 3a33b1a
Copy full SHA for 3a33b1a

File tree

3 files changed

+18
-0
lines changed
Filter options

3 files changed

+18
-0
lines changed

‎NEWS.md

Copy file name to clipboardExpand all lines: NEWS.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# 4.10.1.9000
22

3+
## Bug fixes
34

5+
* `ggplotly()` no longer errors given a `geom_area()` with 1 or less data points (error introduced by new behavior in ggplot2 v3.4.0). (#2209)
46

57

68
# 4.10.1

‎R/layers2traces.R

Copy file name to clipboardExpand all lines: R/layers2traces.R
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,7 @@ make_error <- function(data, params, xy = "x") {
10611061
# (note this function is also used for geom_smooth)
10621062
ribbon_dat <- function(dat) {
10631063
n <- nrow(dat)
1064+
if (n == 0) return(dat)
10641065
o <- order(dat[["x"]])
10651066
o2 <- order(dat[["x"]], decreasing = TRUE)
10661067
used <- c("x", "ymin", "ymax", "y")

‎tests/testthat/test-ggplot-area.R

Copy file name to clipboardExpand all lines: tests/testthat/test-ggplot-area.R
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,18 @@ test_that("traces are ordered correctly in geom_area", {
6868
}
6969
})
7070

71+
72+
test_that("Can handle an 'empty' geom_area()", {
73+
p <- ggplot(data.frame(x = 1, y = 1), aes(x, y)) +
74+
geom_area() +
75+
geom_point()
76+
77+
l <- ggplotly(p)$x
78+
79+
expect_length(l$data, 2)
80+
81+
expect_false(l$data[[1]]$visible)
82+
expect_true(l$data[[2]]$x == 1)
83+
expect_true(l$data[[2]]$y == 1)
84+
expect_true(l$data[[2]]$mode == "markers")
85+
})

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.