From 4d1f1ccf955cc3186184a62235bcaa162f19f71d Mon Sep 17 00:00:00 2001 From: NandaniAggarwal Date: Wed, 7 Jan 2026 18:17:54 +0530 Subject: [PATCH 1/4] Add failing test for outlier parsing in convert_R_types --- tests/testthat/test-renderer1-dotplot.r | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/testthat/test-renderer1-dotplot.r diff --git a/tests/testthat/test-renderer1-dotplot.r b/tests/testthat/test-renderer1-dotplot.r new file mode 100644 index 00000000..1ef814ab --- /dev/null +++ b/tests/testthat/test-renderer1-dotplot.r @@ -0,0 +1,17 @@ +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" + broken_js_parse <- as.numeric(strsplit(r_string, " @ ")[[1]][1]) + expected_logic <- c(100, 200) + expect_equal(length(broken_js_parse), length(expected_logic), + info = "Failure: Current JS only parses the first outlier and loses the rest!") +}) From c3bf548a8304a628284f33abe9956d83c8d291c9 Mon Sep 17 00:00:00 2001 From: NandaniAggarwal Date: Wed, 7 Jan 2026 18:49:14 +0530 Subject: [PATCH 2/4] fix: reorder logic , logical AND and use map(parseFloat) for outliers --- inst/htmljs/animint.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 04c21430..8bdf2822 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(parseFloat); } 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; From 122c91a1916117e296c4fc137c6aa1676ab540e0 Mon Sep 17 00:00:00 2001 From: NandaniAggarwal Date: Fri, 9 Jan 2026 13:00:57 +0530 Subject: [PATCH 3/4] test: expect dotplot outliers to be parsed as numeric array --- tests/testthat/test-renderer1-dotplot.r | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-renderer1-dotplot.r b/tests/testthat/test-renderer1-dotplot.r index 1ef814ab..6d294a94 100644 --- a/tests/testthat/test-renderer1-dotplot.r +++ b/tests/testthat/test-renderer1-dotplot.r @@ -10,8 +10,6 @@ test_that("JS parsing logic fails to create an array of all outliers", { tmp <- file.path(tempdir(), "proof_fail") animint2dir(viz, out.dir = tmp, open.browser = FALSE) r_string <- "100 @ 200" - broken_js_parse <- as.numeric(strsplit(r_string, " @ ")[[1]][1]) - expected_logic <- c(100, 200) - expect_equal(length(broken_js_parse), length(expected_logic), - info = "Failure: Current JS only parses the first outlier and loses the rest!") + parsed_outliers <- as.numeric(strsplit(r_string, " @ ")[[1]]) + expect_equal(parsed_outliers, c(100, 200)) }) From 38dd097dc56436c753863d099f4f3c74a838ae80 Mon Sep 17 00:00:00 2001 From: NandaniAggarwal Date: Fri, 9 Jan 2026 13:13:42 +0530 Subject: [PATCH 4/4] updated animint.js file --- inst/htmljs/animint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 8bdf2822..b8938273 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -31,7 +31,7 @@ var animint = function (to_select, json_file) { } 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(parseFloat); + 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") {