Skip to content

Commit aee4d91

Browse files
jrwishartchschan
authored andcommitted
DS-4804 Real fix this time
1 parent 58ba959 commit aee4d91

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
@@ -361,13 +361,18 @@ test_that("group_by() on a plotly object doesn't produce warning", {
361361
test_that("Check QTables dont cause errors", {
362362
.createQTableArray <- function(n, class.name)
363363
structure(
364-
array(runif(n), dim = c(n, 1L)),
364+
array(runif(n), dim = n),
365365
class = class.name
366366
)
367367
s <- data.frame(
368368
x = .createQTableArray(10, "QTable"),
369-
y = .createQTableArray(10, "qTable")
369+
x2 = .createQTableArray(10, "qTable"),
370+
y = factor(letters[1:10])
370371
)
371-
expect_error(p <- plot_ly(s, x = ~x, y = ~y), NA)
372+
expect_error(p <- plot_ly(s) |>
373+
add_segments(x = ~x, xend = ~x2, y = ~y, yend = ~y, showlegend = FALSE) |>
374+
add_markers(x = ~x, xend = ~y, y = ~y, name = "foo", color = I("orange"), showlegend = FALSE) |>
375+
add_markers(x = ~x2, xend = ~y, y = ~y, name = "bar", color = I("blue"), showlegend = FALSE),
376+
NA)
372377
expect_error(print(p), NA)
373378
})

0 commit comments

Comments
 (0)