Skip to content

Commit 6ca747d

Browse files
committed
Add test to check that ggplotly does not break discrete x-axis in facet panels with only one category.
1 parent dfa2c6a commit 6ca747d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/testthat/test-facet-axis.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
test_that("ggplotly does not break discrete x-axis with facet_yyyy in panels > 1 with only one category", {
2+
d <- data.frame(cat = c("A", "A", "A"), pan = paste("Panel", c(1, 2, 2)))
3+
gp <- ggplot(d, aes(cat)) +
4+
geom_bar() +
5+
facet_wrap(~pan)
6+
L <- plotly_build(ggplotly(gp))
7+
# tickvals, ticktext and categoryarray have class 'AsIs'
8+
expect_equal(class(L$x$layout$xaxis2$tickvals), "AsIs")
9+
expect_equal(class(L$x$layout$xaxis2$ticktext), "AsIs")
10+
expect_equal(class(L$x$layout$xaxis2$categoryarray), "AsIs")
11+
})

0 commit comments

Comments
 (0)