Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions inst/htmljs/animint.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ var animint = function (to_select, json_file) {
d[v_name] = parseInt(d[v_name]);
} else if (r_type == "numeric") {
d[v_name] = parseFloat(d[v_name]);
} else if (r_type == "character" && v_name == "outliers") {
d[v_name] = d[v_name].split(" @ ").map(x => parseFloat(x));
} else if (r_type == "factor" || r_type == "rgb"
|| r_type == "linetype" || r_type == "label"
|| r_type == "character") {
// keep it as a character
} else if (r_type == "character" & v_name == "outliers") {
d[v_name] = parseFloat(d[v_name].split(" @ "));
}
}
}
}
return d;
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-renderer1-dotplot.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
library(testthat)
library(animint2)
library(jsonlite)
test_that("JS parsing logic fails to create an array of all outliers", {
ggplot <- animint2:::ggplot
aes <- animint2:::aes
geom_dotplot <- animint2:::geom_dotplot
df <- data.frame(x = "A", y = c(1, 1.1, 1.2, 1.3, 100, 200))
viz <- list(dotplot = ggplot() + geom_dotplot(aes(x, y), data = df))
tmp <- file.path(tempdir(), "proof_fail")
animint2dir(viz, out.dir = tmp, open.browser = FALSE)
r_string <- "100 @ 200"
parsed_outliers <- as.numeric(strsplit(r_string, " @ ")[[1]])
expect_equal(parsed_outliers, c(100, 200))
})
Loading