forked from animint/animint2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-renderer4-NA-separate-lines.R
43 lines (36 loc) · 1.36 KB
/
test-renderer4-NA-separate-lines.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
acontext("NA separate lines")
data(txhousing)
## ggplot2 draws separate lines when there are missing values.
## san.marcos <- subset(txhousing, city=="San Marcos")
## a_plot()+
## a_geom_line(a_aes(x = date, y = median),
## data=san.marcos)
viz <- list(
ggdata=a_plot(txhousing)+
a_geom_line(a_aes(x = date, y = median, group = city),
clickSelects="city",
alpha = 0.6),
selected=a_plot()+
a_geom_line(a_aes(x = date, y = median, group = city),
showSelected="city",
data=txhousing),
first=list(city="San Marcos")
)
info <- animint2HTML(viz)
test_that("no NA in tsv files", {
a_geom1.tsv <- file.path("animint-htmltest", "a_geom1_line_ggdata_chunk1.tsv")
a_geom1.data <- read.table(a_geom1.tsv, sep="\t", header=TRUE)
expect_equal(sum(is.na(a_geom1.data)), 0)
})
test_that("three <path> rendered for highlighted San Marcos", {
xpath <- '//g[@class="a_geom1_line_ggdata"]//path'
path.list <- getNodeSet(info$html, xpath)
opacity.str <- getStyleValue(info$html, xpath, "opacity")
opacity.num <- as.numeric(opacity.str)
hilite.list <- path.list[opacity.num == 0.6]
expect_equal(length(hilite.list), 3)
})
test_that("three <path> rendered for selected San Marcos", {
path.list <- getNodeSet(info$html, '//g[@class="a_geom2_line_selected"]//path')
expect_equal(length(path.list), 3)
})