diff --git a/R/ggplotly.R b/R/ggplotly.R index e29dd2b907..1c728be0f2 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -1302,6 +1302,7 @@ italic <- function(x) paste("", x, "") # if a vector that has one unique value (ignoring missings), return that value uniq <- function(x) { + x <- remove_class(x, "TeX") u <- unique(x) if (identical(u, NA) || length(u) == 0) return(u) u <- u[!is.na(u)] @@ -1432,4 +1433,4 @@ getAesMap <- function(plot, layer) { } else { layer$mapping } -} +} \ No newline at end of file diff --git a/tests/testthat/_snaps/ggplot-theme/theme-marker-default.svg b/tests/testthat/_snaps/ggplot-theme/theme-marker-default.svg index fe353c297e..85424aa0cd 100644 --- a/tests/testthat/_snaps/ggplot-theme/theme-marker-default.svg +++ b/tests/testthat/_snaps/ggplot-theme/theme-marker-default.svg @@ -1 +1 @@ -2340.40.81.21.6countrypopulationParaguayPeruPhilippineseduilln +2340.40.81.21.6countrypopulationParaguayPeruPhilippineseduilln diff --git a/tests/testthat/_snaps/latex2exp/latex2exp-rendering.svg b/tests/testthat/_snaps/latex2exp/latex2exp-rendering.svg new file mode 100644 index 0000000000..e36e940e80 --- /dev/null +++ b/tests/testthat/_snaps/latex2exp/latex2exp-rendering.svg @@ -0,0 +1 @@ +0.9500.9751.0001.0251.050A diff --git a/tests/testthat/_snaps/plotly-area/add-area.svg b/tests/testthat/_snaps/plotly-area/add-area.svg new file mode 100644 index 0000000000..467003cc86 --- /dev/null +++ b/tests/testthat/_snaps/plotly-area/add-area.svg @@ -0,0 +1 @@ +NorthN-EEastS-ESouthS-WWestN-W0%50%100%150%200%11-14 m/s8-11 m/s5-8 m/sless than m/s diff --git a/tests/testthat/helper-vdiffr.R b/tests/testthat/helper-vdiffr.R index b27435a1e8..e7b90c09a5 100644 --- a/tests/testthat/helper-vdiffr.R +++ b/tests/testthat/helper-vdiffr.R @@ -51,12 +51,12 @@ write_plotly_svg <- function(p, file) { # strip out non-deterministic fullLayout.uid # TODO: if and when plotly provides an API to pre-specify, use it! - svg_txt <- readLines(file, warn = FALSE) + svg_txt <- readLines(basename(file), warn = FALSE) strextract <- function(str, pattern) regmatches(str, regexpr(pattern, str)) def <- strextract(svg_txt, 'defs id=\\"defs-[[:alnum:]]+\\"') uid <- sub("defs-", "", strextract(def, "defs-[[:alnum:]]+")) svg_txt <- gsub(uid, "", svg_txt, fixed = TRUE) - writeLines(svg_txt, file) + writeLines(svg_txt, basename(file)) } # copied from vdiffr diff --git a/tests/testthat/test-latex2exp.R b/tests/testthat/test-latex2exp.R new file mode 100644 index 0000000000..59e0fe03bc --- /dev/null +++ b/tests/testthat/test-latex2exp.R @@ -0,0 +1,9 @@ +library(latex2exp) + +test_that("latex2exp expressions render correctly", { + p <- qplot(1, "A")+ + ylab(TeX("$\\frac{2hc^2}{\\lambda^\\beta}$"))+ + xlab(TeX("$\\alpha$")) + + expect_doppelganger(config(ggplotly(p), mathjax="cdn"), "latex2exp-rendering") +}) diff --git a/tests/testthat/test-plotly-area.R b/tests/testthat/test-plotly-area.R new file mode 100644 index 0000000000..94a52a5585 --- /dev/null +++ b/tests/testthat/test-plotly-area.R @@ -0,0 +1,12 @@ +test_that("add_area() works", { + data(wind) + p <- plot_ly(wind, r = ~r, theta = ~t) %>% + add_area(color = ~nms) %>% + layout( + polar = list( + radialaxis = list(ticksuffix = "%"), + angularaxis = list(rotation = 90) + ) + ) + expect_doppelganger_built(p, "add-area") +})