diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js
index 04c21430..b8938273 100644
--- a/inst/htmljs/animint.js
+++ b/inst/htmljs/animint.js
@@ -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;
diff --git a/tests/testthat/test-renderer1-dotplot.r b/tests/testthat/test-renderer1-dotplot.r
new file mode 100644
index 00000000..6d294a94
--- /dev/null
+++ b/tests/testthat/test-renderer1-dotplot.r
@@ -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))
+})