From d677525ef7057033393750fdffd750e58109c7d8 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Thu, 15 Aug 2019 15:24:20 -0700 Subject: [PATCH 1/3] failing test --- tests/testthat/test-renderer1-legends.R | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/testthat/test-renderer1-legends.R b/tests/testthat/test-renderer1-legends.R index a446fe27a..b5feaa043 100644 --- a/tests/testthat/test-renderer1-legends.R +++ b/tests/testthat/test-renderer1-legends.R @@ -1,5 +1,4 @@ acontext("legends") - data(WorldBank, package="animint2") breaks <- 10^(4:9) viz <- @@ -69,17 +68,17 @@ test_that('hiding all legends works with theme(legend.position="none")',{ error.types <- data.frame(x=1:3, status=c("correct", "false positive", "false negative")) -gg <- +gg <- ggplot(error.types)+ geom_point(aes(x, x))+ geom_tallrect(aes(xmin=x, xmax=x+0.5, fill=x), color="black") -expected.legend.list <- +expected.legend.list <- list(increasing=1:3, default=seq(3, 1, by=-0.5), decreasing=3:1) - + test_that("renderer shows legend entries in correct order", { viz <- list(increasing=gg+ @@ -89,7 +88,7 @@ test_that("renderer shows legend entries in correct order", { default=gg) info <- animint2HTML(viz) ##sapply(info$plots, function(p)sapply(p$legend$x$entries, "[[", "label")) - + ## NOTE: it is important to test the renderer here (not the ## compiler) since maybe the order specified in the plot.json file ## is not the same as the order of appearance on the web page. @@ -112,3 +111,19 @@ test_that("renderer shows legend entries in correct order", { expect_equal(value.num, expected.entries) } }) + +gg <- ggplot()+ + geom_line(aes( + year, life.expectancy, group=country, colour=region), + clickSelects="country", + data=WorldBank, size=3, alpha=3/5) +viz <- list( + noLegends=gg+ + guides(color="none"), + zoom=gg+coord_cartesian(xlim=c(1970, 2000), ylim=c(30, 70))) +test_that("ok to have two plots based on a common plot", { + info <- animint2HTML(viz) + p1 <- getNodeSet(info$html, '//g[@class="geom1_line_noLegends"]//path') + p2 <- getNodeSet(info$html, '//g[@class="geom2_line_zoom"]//path') + expect_equal(length(p2), length(p2)) +}) From 4adbfe0361f8b3bc8f2e45bad9278a223767c0b0 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Thu, 15 Aug 2019 15:47:12 -0700 Subject: [PATCH 2/3] test p1 != p2 --- tests/testthat/test-renderer1-legends.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-renderer1-legends.R b/tests/testthat/test-renderer1-legends.R index b5feaa043..fc4bfa2f0 100644 --- a/tests/testthat/test-renderer1-legends.R +++ b/tests/testthat/test-renderer1-legends.R @@ -125,5 +125,5 @@ test_that("ok to have two plots based on a common plot", { info <- animint2HTML(viz) p1 <- getNodeSet(info$html, '//g[@class="geom1_line_noLegends"]//path') p2 <- getNodeSet(info$html, '//g[@class="geom2_line_zoom"]//path') - expect_equal(length(p2), length(p2)) + expect_equal(length(p1), length(p2)) }) From a48fda8ca5e026c449ae6cceeedc18a0cdb9f581 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Thu, 15 Aug 2019 15:47:23 -0700 Subject: [PATCH 3/3] do not replace NA --- R/z_animint.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/z_animint.R b/R/z_animint.R index 41454f187..b9d0073a3 100644 --- a/R/z_animint.R +++ b/R/z_animint.R @@ -785,7 +785,7 @@ saveLayer <- function(l, d, meta, layer_name, ggplot, built, AnimationInfo){ } extreme.vec <- range.mat[row.i, panel.vec] cmp <- cmp.list[[row.i]] - to.rep <- cmp(xy.col.df, extreme.vec) + to.rep <- cmp(xy.col.df, extreme.vec) & !is.na(xy.col.df) row.vec <- row(to.rep)[to.rep] xy.col.df[to.rep] <- extreme.vec[row.vec] }