File: test-facet-axis.R

package info (click to toggle)
r-cran-plotly 4.10.4%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 30,636 kB
  • sloc: javascript: 195,272; sh: 24; makefile: 6
file content (15 lines) | stat: -rw-r--r-- 628 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
test_that("ggplotly does not break discrete x-axis with facet_yyyy in panels > 1 with only one category", {
  d <- data.frame(cat = c("A", "A", "A"), pan = paste("Panel", c(1, 2, 2)))
  gp <- ggplot(d, aes(cat)) +
    geom_bar() +
    facet_wrap(~pan)
  L <- plotly_build(ggplotly(gp))
  # tickvals, ticktext and categoryarray have class 'AsIs'
  lapply(L$x$layout[c("xaxis", "xaxis2")], function(axis) {
    expect_s3_class(axis$tickvals, "AsIs")
    expect_s3_class(axis$ticktext, "AsIs")
    expect_true(axis$ticktext == "A")
    expect_s3_class(axis$categoryarray, "AsIs")
    expect_true(axis$categoryarray == "A")
  })
})