Skip to content

Commit 39337c2

Browse files
committed
DS-4804 Real fix this time
1 parent 8088bdc commit 39337c2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

R/plotly.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, name,
140140
if (!is.data.frame(data) && !crosstalk::is.SharedData(data)) {
141141
stop("First argument, `data`, must be a data frame or shared data.", call. = FALSE)
142142
}
143+
143144
if (is.data.frame(data) && nrow(data) > 0L) {
144145
qtables <- vapply(data, inherits, logical(1L), c("qTable", "QTable"))
145146
if (any(qtables))

tests/testthat/test-plotly.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,18 @@ test_that("group_by() on a plotly object doesn't produce warning", {
362362
test_that("Check QTables dont cause errors", {
363363
.createQTableArray <- function(n, class.name)
364364
structure(
365-
array(runif(n), dim = c(n, 1L)),
365+
array(runif(n), dim = n),
366366
class = class.name
367367
)
368368
s <- data.frame(
369369
x = .createQTableArray(10, "QTable"),
370-
y = .createQTableArray(10, "qTable")
370+
x2 = .createQTableArray(10, "qTable"),
371+
y = factor(letters[1:10])
371372
)
372-
expect_error(p <- plot_ly(s, x = ~x, y = ~y), NA)
373+
expect_error(p <- plot_ly(s) |>
374+
add_segments(x = ~x, xend = ~x2, y = ~y, yend = ~y, showlegend = FALSE) |>
375+
add_markers(x = ~x, xend = ~y, y = ~y, name = "foo", color = I("orange"), showlegend = FALSE) |>
376+
add_markers(x = ~x2, xend = ~y, y = ~y, name = "bar", color = I("blue"), showlegend = FALSE),
377+
NA)
373378
expect_error(print(p), NA)
374379
})

0 commit comments

Comments
 (0)