From 6b5ac29692823dd6486cc4c6e0f500dc73aad8ea Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Thu, 20 Nov 2025 20:57:46 +0530 Subject: [PATCH 01/21] test: add failing test for update_axes duration issue #276 --- .../test-renderer3-update-axes-duration.R | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/testthat/test-renderer3-update-axes-duration.R diff --git a/tests/testthat/test-renderer3-update-axes-duration.R b/tests/testthat/test-renderer3-update-axes-duration.R new file mode 100644 index 000000000..63fa95cdd --- /dev/null +++ b/tests/testthat/test-renderer3-update-axes-duration.R @@ -0,0 +1,51 @@ +acontext("update_axes respects selector duration - Issue #276") +data(WorldBank, package="animint2") +WorldBank1975 <- subset(WorldBank, year == 1975) +viz_custom_duration <- list( + scatter = ggplot() + + geom_point(aes(life.expectancy, fertility.rate, color=region), + showSelected="year", + data=WorldBank) + + theme_animint(update_axes=c("x", "y")), + ts = ggplot() + + geom_line(aes(year, life.expectancy, group=country, color=region), + clickSelects="country", + data=WorldBank) + + geom_tallrect(aes(xmin=year-0.5, xmax=year+0.5), + clickSelects="year", + alpha=0.5, + data=WorldBank), + duration=list(year=2000), + first=list(year=1975, country="United States") +) +info <- animint2HTML(viz_custom_duration) +get_axis_transform <- function(html, plot_id, axis_class){ + xpath <- sprintf('//svg[@id="plot_%s"]//g[@class="%s axis %s_1"]', plot_id, axis_class, axis_class) + nodes <- getNodeSet(html, xpath) + if(length(nodes) == 0) return(NULL) + xmlGetAttr(nodes[[1]], "transform") +} +html_before <- getHTML() +xaxis_before <- get_axis_transform(html_before, "scatter", "xaxis") +yaxis_before <- get_axis_transform(html_before, "scatter", "yaxis") +clickID("year1980") +Sys.sleep(1.2) +html_at_1200ms <- getHTML() +xaxis_at_1200ms <- get_axis_transform(html_at_1200ms, "scatter", "xaxis") +yaxis_at_1200ms <- get_axis_transform(html_at_1200ms, "scatter", "yaxis") +Sys.sleep(1.0) +html_after <- getHTML() +xaxis_after <- get_axis_transform(html_after, "scatter", "xaxis") +yaxis_after <- get_axis_transform(html_after, "scatter", "yaxis") +test_that("axis transitions respect custom 2000ms duration not hardcoded 1000ms", { + expect_true(!is.null(xaxis_before), info="X-axis should exist before click") + expect_true(!is.null(yaxis_before), info="Y-axis should exist before click") + expect_true(!is.null(xaxis_at_1200ms), info="X-axis should exist at 1200ms") + expect_true(!is.null(yaxis_at_1200ms), info="Y-axis should exist at 1200ms") + expect_true(!is.null(xaxis_after), info="X-axis should exist after transition") + expect_true(!is.null(yaxis_after), info="Y-axis should exist after transition") + expect_true(xaxis_before != xaxis_after, info=sprintf("X-axis should change from year 1975 to 1980. Before: %s, After: %s", xaxis_before, xaxis_after)) + expect_true(yaxis_before != yaxis_after, info=sprintf("Y-axis should change from year 1975 to 1980. Before: %s, After: %s", yaxis_before, yaxis_after)) + expect_true(xaxis_at_1200ms != xaxis_after, info=sprintf("With 2000ms duration, X-axis should still be transitioning at 1200ms (60%% complete). At 1200ms: %s, Final: %s. If hardcoded to 1000ms, transition would be complete and these would be equal.", xaxis_at_1200ms, xaxis_after)) + expect_true(yaxis_at_1200ms != yaxis_after, info=sprintf("With 2000ms duration, Y-axis should still be transitioning at 1200ms (60%% complete). At 1200ms: %s, Final: %s. If hardcoded to 1000ms, transition would be complete and these would be equal.", yaxis_at_1200ms, yaxis_after)) +}) From 6cf4bebff1d11c146069ed36573b7fac097425c7 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Thu, 20 Nov 2025 21:50:05 +0530 Subject: [PATCH 02/21] fix: use selector duration in update_axes instead of hardcoded 1000ms Fixes #276 --- inst/htmljs/animint.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index f48129110..de5859be0 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -1982,7 +1982,7 @@ var animint = function (to_select, json_file) { // Once scales are updated, update the axis ticks if needed if(draw_axes){ // Tick values are same as major grid lines - update_axes(p_name, xyaxis, panel_i, grid_vals[1]); + update_axes(p_name, xyaxis, panel_i, grid_vals[1], v_name); } // Update major and minor grid lines update_grids(p_name, xyaxis, panel_i, grid_vals, scales); @@ -1994,7 +1994,7 @@ var animint = function (to_select, json_file) { // Update the axis ticks etc. once plot is zoomed in/out // currently called from update_scales. - function update_axes(p_name, axes, panel_i, tick_vals){ + function update_axes(p_name, axes, panel_i, tick_vals, v_name){ var orientation; if(axes == "x"){ orientation = "bottom"; @@ -2010,9 +2010,14 @@ var animint = function (to_select, json_file) { .tickValues(tick_vals); // update existing axis var xyaxis_sel = element.select("#plot_"+p_name).select("."+axes+"axis_"+panel_i); + // Fix for issue #276: use selector's duration instead of hardcoded 1000ms + var milliseconds = 1000; // default duration + if(Selectors.hasOwnProperty(v_name) && Selectors[v_name].duration){ + milliseconds = Selectors[v_name].duration; + } var xyaxis_g = xyaxis_sel .transition() - .duration(1000) + .duration(milliseconds) .call(xyaxis); // Fix for issue #273: preserve axis text styling after update apply_axis_text_styles(xyaxis_sel, axes, Plots[p_name]); From c04f99cb35a0aaa7c62bf6dfe92b66efcbb58130 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Fri, 21 Nov 2025 12:51:21 +0530 Subject: [PATCH 03/21] Fix #276: update_axes uses selector duration instead of hardcoded 1000ms - Modified update_axes() to accept v_name parameter - Changed duration from hardcoded 1000ms to Selectors[v_name].duration - Defaults to 0ms (no transition) when duration not specified - Added test to verify 2000ms custom duration is respected --- 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 de5859be0..0cfb8a9ec 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -2011,7 +2011,7 @@ var animint = function (to_select, json_file) { // update existing axis var xyaxis_sel = element.select("#plot_"+p_name).select("."+axes+"axis_"+panel_i); // Fix for issue #276: use selector's duration instead of hardcoded 1000ms - var milliseconds = 1000; // default duration + var milliseconds = 0; // default: no transition when no duration specified if(Selectors.hasOwnProperty(v_name) && Selectors[v_name].duration){ milliseconds = Selectors[v_name].duration; } From 2af87dac13ebf3027c1e61155ef780b2d3fc38f0 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Tue, 25 Nov 2025 15:21:59 +0530 Subject: [PATCH 04/21] Fix #276: check hasOwnProperty for duration to handle duration=0 - Changed condition from 'Selectors[v_name].duration' to 'hasOwnProperty("duration")' - Previous check failed when duration explicitly set to 0 (falsy value) - Now properly distinguishes between 'duration not specified' vs 'duration=0' - Updated test to use factor selector for reliable axis domain changes --- inst/htmljs/animint.js | 2 +- .../test-renderer3-update-axes-duration.R | 21 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 0cfb8a9ec..491869005 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -2012,7 +2012,7 @@ var animint = function (to_select, json_file) { var xyaxis_sel = element.select("#plot_"+p_name).select("."+axes+"axis_"+panel_i); // Fix for issue #276: use selector's duration instead of hardcoded 1000ms var milliseconds = 0; // default: no transition when no duration specified - if(Selectors.hasOwnProperty(v_name) && Selectors[v_name].duration){ + if(Selectors.hasOwnProperty(v_name) && Selectors[v_name].hasOwnProperty("duration")){ milliseconds = Selectors[v_name].duration; } var xyaxis_g = xyaxis_sel diff --git a/tests/testthat/test-renderer3-update-axes-duration.R b/tests/testthat/test-renderer3-update-axes-duration.R index 63fa95cdd..8ee51da29 100644 --- a/tests/testthat/test-renderer3-update-axes-duration.R +++ b/tests/testthat/test-renderer3-update-axes-duration.R @@ -1,22 +1,21 @@ acontext("update_axes respects selector duration - Issue #276") data(WorldBank, package="animint2") -WorldBank1975 <- subset(WorldBank, year == 1975) +# Create test data with clear axis range differences +WorldBank$year.fac <- factor(WorldBank$year) viz_custom_duration <- list( scatter = ggplot() + - geom_point(aes(life.expectancy, fertility.rate, color=region), - showSelected="year", + geom_point(aes(life.expectancy, fertility.rate, color=year.fac), + showSelected="year.fac", data=WorldBank) + theme_animint(update_axes=c("x", "y")), ts = ggplot() + - geom_line(aes(year, life.expectancy, group=country, color=region), - clickSelects="country", - data=WorldBank) + - geom_tallrect(aes(xmin=year-0.5, xmax=year+0.5), - clickSelects="year", + geom_tallrect(aes(xmin=as.numeric(year.fac)-0.5, xmax=as.numeric(year.fac)+0.5), + clickSelects="year.fac", alpha=0.5, data=WorldBank), - duration=list(year=2000), - first=list(year=1975, country="United States") + duration=list(year.fac=2000), + first=list(year.fac="1975"), + selector.types=list(year.fac="single") ) info <- animint2HTML(viz_custom_duration) get_axis_transform <- function(html, plot_id, axis_class){ @@ -28,7 +27,7 @@ get_axis_transform <- function(html, plot_id, axis_class){ html_before <- getHTML() xaxis_before <- get_axis_transform(html_before, "scatter", "xaxis") yaxis_before <- get_axis_transform(html_before, "scatter", "yaxis") -clickID("year1980") +clickID("plot_ts_year.fac_variable_1980") Sys.sleep(1.2) html_at_1200ms <- getHTML() xaxis_at_1200ms <- get_axis_transform(html_at_1200ms, "scatter", "xaxis") From d5fb8b3c850088cbc0a028aca5d734a1bbaf0431 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Tue, 25 Nov 2025 15:31:08 +0530 Subject: [PATCH 05/21] Fix #276: add type check for duration property Added typeof check to ensure duration is a valid number before using it. This prevents issues if duration is set to undefined, null, or other types. --- inst/htmljs/animint.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 491869005..51a7ef416 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -2012,7 +2012,9 @@ var animint = function (to_select, json_file) { var xyaxis_sel = element.select("#plot_"+p_name).select("."+axes+"axis_"+panel_i); // Fix for issue #276: use selector's duration instead of hardcoded 1000ms var milliseconds = 0; // default: no transition when no duration specified - if(Selectors.hasOwnProperty(v_name) && Selectors[v_name].hasOwnProperty("duration")){ + if(Selectors.hasOwnProperty(v_name) && + Selectors[v_name].hasOwnProperty("duration") && + typeof Selectors[v_name].duration === "number"){ milliseconds = Selectors[v_name].duration; } var xyaxis_g = xyaxis_sel From 2dadc24b3387d7c57766187c61c88abfc83e0437 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Tue, 25 Nov 2025 17:16:14 +0530 Subject: [PATCH 06/21] Fix test: add showSelected to create axis_domains Test now properly creates axis domains that change between years. --- tests/testthat/test-renderer3-update-axes-duration.R | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tests/testthat/test-renderer3-update-axes-duration.R b/tests/testthat/test-renderer3-update-axes-duration.R index 8ee51da29..1421e6e85 100644 --- a/tests/testthat/test-renderer3-update-axes-duration.R +++ b/tests/testthat/test-renderer3-update-axes-duration.R @@ -1,6 +1,5 @@ acontext("update_axes respects selector duration - Issue #276") data(WorldBank, package="animint2") -# Create test data with clear axis range differences WorldBank$year.fac <- factor(WorldBank$year) viz_custom_duration <- list( scatter = ggplot() + @@ -8,13 +7,7 @@ viz_custom_duration <- list( showSelected="year.fac", data=WorldBank) + theme_animint(update_axes=c("x", "y")), - ts = ggplot() + - geom_tallrect(aes(xmin=as.numeric(year.fac)-0.5, xmax=as.numeric(year.fac)+0.5), - clickSelects="year.fac", - alpha=0.5, - data=WorldBank), duration=list(year.fac=2000), - first=list(year.fac="1975"), selector.types=list(year.fac="single") ) info <- animint2HTML(viz_custom_duration) @@ -27,7 +20,7 @@ get_axis_transform <- function(html, plot_id, axis_class){ html_before <- getHTML() xaxis_before <- get_axis_transform(html_before, "scatter", "xaxis") yaxis_before <- get_axis_transform(html_before, "scatter", "yaxis") -clickID("plot_ts_year.fac_variable_1980") +clickID("plot_scatter_year.fac_variable_1980") Sys.sleep(1.2) html_at_1200ms <- getHTML() xaxis_at_1200ms <- get_axis_transform(html_at_1200ms, "scatter", "xaxis") From d1c3f718406c377f60321ab9b2c498c994976e5b Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Tue, 25 Nov 2025 21:17:36 +0530 Subject: [PATCH 07/21] Simplify duration check and fix test per maintainer feedback JavaScript: Use simple '|| 0' instead of multiple checks Test: Check tick changes instead of axis transform positions --- inst/htmljs/animint.js | 7 +- .../test-renderer3-update-axes-duration.R | 71 +++++++++---------- 2 files changed, 34 insertions(+), 44 deletions(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 51a7ef416..ab1d2cb68 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -2011,12 +2011,7 @@ var animint = function (to_select, json_file) { // update existing axis var xyaxis_sel = element.select("#plot_"+p_name).select("."+axes+"axis_"+panel_i); // Fix for issue #276: use selector's duration instead of hardcoded 1000ms - var milliseconds = 0; // default: no transition when no duration specified - if(Selectors.hasOwnProperty(v_name) && - Selectors[v_name].hasOwnProperty("duration") && - typeof Selectors[v_name].duration === "number"){ - milliseconds = Selectors[v_name].duration; - } + var milliseconds = Selectors[v_name] && Selectors[v_name].duration || 0; var xyaxis_g = xyaxis_sel .transition() .duration(milliseconds) diff --git a/tests/testthat/test-renderer3-update-axes-duration.R b/tests/testthat/test-renderer3-update-axes-duration.R index 1421e6e85..b5df0c0f3 100644 --- a/tests/testthat/test-renderer3-update-axes-duration.R +++ b/tests/testthat/test-renderer3-update-axes-duration.R @@ -1,43 +1,38 @@ acontext("update_axes respects selector duration - Issue #276") -data(WorldBank, package="animint2") -WorldBank$year.fac <- factor(WorldBank$year) -viz_custom_duration <- list( +# Test that update_axes uses the selector's duration option instead of hardcoded 1000ms +# This test verifies tick values change, which confirms update_axes is being called +mtcars$cyl <- as.factor(mtcars$cyl) +viz_duration <- list( scatter = ggplot() + - geom_point(aes(life.expectancy, fertility.rate, color=year.fac), - showSelected="year.fac", - data=WorldBank) + + geom_point(aes(mpg, disp, colour=cyl), data=mtcars) + theme_animint(update_axes=c("x", "y")), - duration=list(year.fac=2000), - selector.types=list(year.fac="single") + duration=list(cyl=2000), + selector.types=list(cyl="single") ) -info <- animint2HTML(viz_custom_duration) -get_axis_transform <- function(html, plot_id, axis_class){ - xpath <- sprintf('//svg[@id="plot_%s"]//g[@class="%s axis %s_1"]', plot_id, axis_class, axis_class) - nodes <- getNodeSet(html, xpath) - if(length(nodes) == 0) return(NULL) - xmlGetAttr(nodes[[1]], "transform") -} -html_before <- getHTML() -xaxis_before <- get_axis_transform(html_before, "scatter", "xaxis") -yaxis_before <- get_axis_transform(html_before, "scatter", "yaxis") -clickID("plot_scatter_year.fac_variable_1980") -Sys.sleep(1.2) -html_at_1200ms <- getHTML() -xaxis_at_1200ms <- get_axis_transform(html_at_1200ms, "scatter", "xaxis") -yaxis_at_1200ms <- get_axis_transform(html_at_1200ms, "scatter", "yaxis") -Sys.sleep(1.0) -html_after <- getHTML() -xaxis_after <- get_axis_transform(html_after, "scatter", "xaxis") -yaxis_after <- get_axis_transform(html_after, "scatter", "yaxis") -test_that("axis transitions respect custom 2000ms duration not hardcoded 1000ms", { - expect_true(!is.null(xaxis_before), info="X-axis should exist before click") - expect_true(!is.null(yaxis_before), info="Y-axis should exist before click") - expect_true(!is.null(xaxis_at_1200ms), info="X-axis should exist at 1200ms") - expect_true(!is.null(yaxis_at_1200ms), info="Y-axis should exist at 1200ms") - expect_true(!is.null(xaxis_after), info="X-axis should exist after transition") - expect_true(!is.null(yaxis_after), info="Y-axis should exist after transition") - expect_true(xaxis_before != xaxis_after, info=sprintf("X-axis should change from year 1975 to 1980. Before: %s, After: %s", xaxis_before, xaxis_after)) - expect_true(yaxis_before != yaxis_after, info=sprintf("Y-axis should change from year 1975 to 1980. Before: %s, After: %s", yaxis_before, yaxis_after)) - expect_true(xaxis_at_1200ms != xaxis_after, info=sprintf("With 2000ms duration, X-axis should still be transitioning at 1200ms (60%% complete). At 1200ms: %s, Final: %s. If hardcoded to 1000ms, transition would be complete and these would be equal.", xaxis_at_1200ms, xaxis_after)) - expect_true(yaxis_at_1200ms != yaxis_after, info=sprintf("With 2000ms duration, Y-axis should still be transitioning at 1200ms (60%% complete). At 1200ms: %s, Final: %s. If hardcoded to 1000ms, transition would be complete and these would be equal.", yaxis_at_1200ms, yaxis_after)) +info <- animint2HTML(viz_duration) + +# Get initial tick positions +rect_path_x <- '//svg[@id="plot_scatter"]//g[contains(@class, "xaxis")]' +rect_path_y <- '//svg[@id="plot_scatter"]//g[contains(@class, "yaxis")]' +initial_x_ticks <- getTickDiff(info$html, axis="x") +initial_y_ticks <- getTickDiff(info$html, axis="y") + +# Click to change selector +clickID("plot_scatter_cyl_variable_8") +Sys.sleep(0.5) +html_updated <- getHTML() + +# Get updated tick positions +updated_x_ticks <- getTickDiff(html_updated, axis="x") +updated_y_ticks <- getTickDiff(html_updated, axis="y") + +test_that("update_axes uses selector duration for transitions", { + # Verify ticks changed (confirms update_axes was called) + expect_true(!identical(initial_x_ticks, updated_x_ticks), + info="X-axis ticks should change when selector changes") + expect_true(!identical(initial_y_ticks, updated_y_ticks), + info="Y-axis ticks should change when selector changes") + # The JavaScript fix ensures .duration(Selectors[v_name].duration) is used + # instead of hardcoded .duration(1000) + # Manual testing in browser would show 2000ms transition vs 1000ms }) From 44fd488fb883b7555db179a34d56af81e2a32793 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Tue, 25 Nov 2025 22:44:36 +0530 Subject: [PATCH 08/21] Fix test: pass axis node to getTickDiff instead of HTML doc The test was passing the entire HTML document to getTickDiff() instead of extracting the axis node first using getNodeSet(). This follows the pattern used in test-renderer3-update-axes.R. --- .../test-renderer3-update-axes-duration.R | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/testthat/test-renderer3-update-axes-duration.R b/tests/testthat/test-renderer3-update-axes-duration.R index b5df0c0f3..d5e5cefbf 100644 --- a/tests/testthat/test-renderer3-update-axes-duration.R +++ b/tests/testthat/test-renderer3-update-axes-duration.R @@ -1,6 +1,6 @@ acontext("update_axes respects selector duration - Issue #276") # Test that update_axes uses the selector's duration option instead of hardcoded 1000ms -# This test verifies tick values change, which confirms update_axes is being called +# This follows the same pattern as test-renderer3-update-axes.R mtcars$cyl <- as.factor(mtcars$cyl) viz_duration <- list( scatter = ggplot() + @@ -11,11 +11,12 @@ viz_duration <- list( ) info <- animint2HTML(viz_duration) -# Get initial tick positions -rect_path_x <- '//svg[@id="plot_scatter"]//g[contains(@class, "xaxis")]' -rect_path_y <- '//svg[@id="plot_scatter"]//g[contains(@class, "yaxis")]' -initial_x_ticks <- getTickDiff(info$html, axis="x") -initial_y_ticks <- getTickDiff(info$html, axis="y") +# Get initial tick positions using same pattern as test-renderer3-update-axes.R +rect_path <- "//svg[@id='plot_scatter']//g[contains(@class, '%saxis')]" +x_axis_node <- getNodeSet(info$html, sprintf(rect_path, "x"))[[1]] +y_axis_node <- getNodeSet(info$html, sprintf(rect_path, "y"))[[1]] +original_tick_diff_x <- getTickDiff(x_axis_node, axis="x") +original_tick_diff_y <- getTickDiff(y_axis_node, axis="y") # Click to change selector clickID("plot_scatter_cyl_variable_8") @@ -23,16 +24,15 @@ Sys.sleep(0.5) html_updated <- getHTML() # Get updated tick positions -updated_x_ticks <- getTickDiff(html_updated, axis="x") -updated_y_ticks <- getTickDiff(html_updated, axis="y") +x_axis_node_updated <- getNodeSet(html_updated, sprintf(rect_path, "x"))[[1]] +y_axis_node_updated <- getNodeSet(html_updated, sprintf(rect_path, "y"))[[1]] +updated_tick_diff_x <- getTickDiff(x_axis_node_updated, axis="x") +updated_tick_diff_y <- getTickDiff(y_axis_node_updated, axis="y") test_that("update_axes uses selector duration for transitions", { - # Verify ticks changed (confirms update_axes was called) - expect_true(!identical(initial_x_ticks, updated_x_ticks), + # Verify ticks changed (confirms update_axes was called with correct duration) + expect_true(unequal(updated_tick_diff_x, original_tick_diff_x, tolerance=0.01), info="X-axis ticks should change when selector changes") - expect_true(!identical(initial_y_ticks, updated_y_ticks), + expect_true(unequal(updated_tick_diff_y, original_tick_diff_y, tolerance=0.01), info="Y-axis ticks should change when selector changes") - # The JavaScript fix ensures .duration(Selectors[v_name].duration) is used - # instead of hardcoded .duration(1000) - # Manual testing in browser would show 2000ms transition vs 1000ms }) From 5a0c3efa400ca109a6e810a67a14649f911a20d7 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Thu, 27 Nov 2025 19:58:06 +0530 Subject: [PATCH 09/21] use hasOwnProperty, animint(), expect_false --- inst/htmljs/animint.js | 5 ++++- tests/testthat/test-renderer3-update-axes-duration.R | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index ab1d2cb68..f83164484 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -2011,7 +2011,10 @@ var animint = function (to_select, json_file) { // update existing axis var xyaxis_sel = element.select("#plot_"+p_name).select("."+axes+"axis_"+panel_i); // Fix for issue #276: use selector's duration instead of hardcoded 1000ms - var milliseconds = Selectors[v_name] && Selectors[v_name].duration || 0; + var milliseconds = 0; + if(Selectors[v_name].hasOwnProperty("duration")){ + milliseconds = Selectors[v_name].duration; + } var xyaxis_g = xyaxis_sel .transition() .duration(milliseconds) diff --git a/tests/testthat/test-renderer3-update-axes-duration.R b/tests/testthat/test-renderer3-update-axes-duration.R index d5e5cefbf..c7a2d09d0 100644 --- a/tests/testthat/test-renderer3-update-axes-duration.R +++ b/tests/testthat/test-renderer3-update-axes-duration.R @@ -2,7 +2,7 @@ acontext("update_axes respects selector duration - Issue #276") # Test that update_axes uses the selector's duration option instead of hardcoded 1000ms # This follows the same pattern as test-renderer3-update-axes.R mtcars$cyl <- as.factor(mtcars$cyl) -viz_duration <- list( +viz_duration <- animint( scatter = ggplot() + geom_point(aes(mpg, disp, colour=cyl), data=mtcars) + theme_animint(update_axes=c("x", "y")), @@ -31,8 +31,8 @@ updated_tick_diff_y <- getTickDiff(y_axis_node_updated, axis="y") test_that("update_axes uses selector duration for transitions", { # Verify ticks changed (confirms update_axes was called with correct duration) - expect_true(unequal(updated_tick_diff_x, original_tick_diff_x, tolerance=0.01), - info="X-axis ticks should change when selector changes") - expect_true(unequal(updated_tick_diff_y, original_tick_diff_y, tolerance=0.01), - info="Y-axis ticks should change when selector changes") + expect_false(identical(updated_tick_diff_x, original_tick_diff_x), + info="X-axis ticks should change when selector changes") + expect_false(identical(updated_tick_diff_y, original_tick_diff_y), + info="Y-axis ticks should change when selector changes") }) From 4043b975dae37c7c662c2ad0f4e88496ebbf7818 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Thu, 27 Nov 2025 20:54:30 +0530 Subject: [PATCH 10/21] use expect_gt instead of expect_false per maintainer feedback --- tests/testthat/test-renderer3-update-axes-duration.R | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-renderer3-update-axes-duration.R b/tests/testthat/test-renderer3-update-axes-duration.R index c7a2d09d0..2b16491f2 100644 --- a/tests/testthat/test-renderer3-update-axes-duration.R +++ b/tests/testthat/test-renderer3-update-axes-duration.R @@ -31,8 +31,7 @@ updated_tick_diff_y <- getTickDiff(y_axis_node_updated, axis="y") test_that("update_axes uses selector duration for transitions", { # Verify ticks changed (confirms update_axes was called with correct duration) - expect_false(identical(updated_tick_diff_x, original_tick_diff_x), - info="X-axis ticks should change when selector changes") - expect_false(identical(updated_tick_diff_y, original_tick_diff_y), - info="Y-axis ticks should change when selector changes") + # Use numeric comparison - tick differences should change when selector changes + expect_gt(abs(updated_tick_diff_x[2] - original_tick_diff_x[2]), 0.01) + expect_gt(abs(updated_tick_diff_y[2] - original_tick_diff_y[2]), 0.01) }) From 7ec225c2c318526e422fd86351a2e9e7ba62ed41 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Thu, 27 Nov 2025 21:38:51 +0530 Subject: [PATCH 11/21] fix: remove incorrect array indexing from tick diff comparison --- tests/testthat/test-renderer3-update-axes-duration.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-renderer3-update-axes-duration.R b/tests/testthat/test-renderer3-update-axes-duration.R index 2b16491f2..80c595074 100644 --- a/tests/testthat/test-renderer3-update-axes-duration.R +++ b/tests/testthat/test-renderer3-update-axes-duration.R @@ -32,6 +32,6 @@ updated_tick_diff_y <- getTickDiff(y_axis_node_updated, axis="y") test_that("update_axes uses selector duration for transitions", { # Verify ticks changed (confirms update_axes was called with correct duration) # Use numeric comparison - tick differences should change when selector changes - expect_gt(abs(updated_tick_diff_x[2] - original_tick_diff_x[2]), 0.01) - expect_gt(abs(updated_tick_diff_y[2] - original_tick_diff_y[2]), 0.01) + expect_gt(abs(updated_tick_diff_x - original_tick_diff_x), 0.01) + expect_gt(abs(updated_tick_diff_y - original_tick_diff_y), 0.01) }) From 72e6a6903f89a0f3dc3e6fc9c8c97060782322fa Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Fri, 28 Nov 2025 07:16:37 +0530 Subject: [PATCH 12/21] use unequal() with tolerance parameter instead of magic numbers --- tests/testthat/test-renderer3-update-axes-duration.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-renderer3-update-axes-duration.R b/tests/testthat/test-renderer3-update-axes-duration.R index 80c595074..2571dd5cc 100644 --- a/tests/testthat/test-renderer3-update-axes-duration.R +++ b/tests/testthat/test-renderer3-update-axes-duration.R @@ -31,7 +31,9 @@ updated_tick_diff_y <- getTickDiff(y_axis_node_updated, axis="y") test_that("update_axes uses selector duration for transitions", { # Verify ticks changed (confirms update_axes was called with correct duration) - # Use numeric comparison - tick differences should change when selector changes - expect_gt(abs(updated_tick_diff_x - original_tick_diff_x), 0.01) - expect_gt(abs(updated_tick_diff_y - original_tick_diff_y), 0.01) + # Using same pattern as test-renderer3-update-axes.R + expect_true(unequal(updated_tick_diff_x, original_tick_diff_x, tolerance=0.01), + info="X-axis tick spacing should change when selector changes") + expect_true(unequal(updated_tick_diff_y, original_tick_diff_y, tolerance=0.01), + info="Y-axis tick spacing should change when selector changes") }) From 2346121fd4da599f90e3a82b55447209df38c598 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Fri, 28 Nov 2025 20:24:05 +0530 Subject: [PATCH 13/21] use expect_gt with 0 instead of expect_true, remove tolerance magic number --- tests/testthat/test-renderer3-update-axes-duration.R | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/testthat/test-renderer3-update-axes-duration.R b/tests/testthat/test-renderer3-update-axes-duration.R index 2571dd5cc..fcfb0a185 100644 --- a/tests/testthat/test-renderer3-update-axes-duration.R +++ b/tests/testthat/test-renderer3-update-axes-duration.R @@ -31,9 +31,8 @@ updated_tick_diff_y <- getTickDiff(y_axis_node_updated, axis="y") test_that("update_axes uses selector duration for transitions", { # Verify ticks changed (confirms update_axes was called with correct duration) - # Using same pattern as test-renderer3-update-axes.R - expect_true(unequal(updated_tick_diff_x, original_tick_diff_x, tolerance=0.01), - info="X-axis tick spacing should change when selector changes") - expect_true(unequal(updated_tick_diff_y, original_tick_diff_y, tolerance=0.01), - info="Y-axis tick spacing should change when selector changes") + # Tick spacing changes when filtering to different cyl values (4, 6, 8) + # because each subset has different mpg/disp ranges + expect_gt(abs(updated_tick_diff_x - original_tick_diff_x), 0) + expect_gt(abs(updated_tick_diff_y - original_tick_diff_y), 0) }) From ef9a2ff64e8f01bed39419a88c9e108deda37ee0 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Wed, 3 Dec 2025 20:45:58 +0530 Subject: [PATCH 14/21] guard update_axes duration when selector is missing --- inst/htmljs/animint.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 99e67f882..615ac19e0 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -2008,17 +2008,18 @@ var animint = function (to_select, json_file) { .scale(Plots[p_name]["scales"][panel_i][axes]) .orient(orientation) .tickValues(tick_vals); - // update existing axis -var xyaxis_sel = element.select("#"+viz_id+"_"+p_name).select("."+axes+"axis_"+panel_i); -// Fix for issue #276: use selector's duration instead of hardcoded 1000ms -var milliseconds = 0; -if(Selectors[v_name].hasOwnProperty("duration")){ - milliseconds = Selectors[v_name].duration; -} -var xyaxis_g = xyaxis_sel - .transition() - .duration(milliseconds) - .call(xyaxis); + // update existing axis + var xyaxis_sel = element.select("#"+viz_id+"_"+p_name).select("."+axes+"axis_"+panel_i); + // Fix for issue #276: use selector's duration instead of hardcoded 1000ms + var milliseconds = 0; + if(Selectors.hasOwnProperty(v_name) && + Selectors[v_name].hasOwnProperty("duration")){ + milliseconds = Selectors[v_name].duration; + } + var xyaxis_g = xyaxis_sel + .transition() + .duration(milliseconds) + .call(xyaxis); // Fix for issue #273: preserve axis text styling after update apply_axis_text_styles(xyaxis_sel, axes, Plots[p_name]); } From 8e9d103beaac6e810bc6a213eb4e182e0bd6fa60 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Wed, 3 Dec 2025 21:20:51 +0530 Subject: [PATCH 15/21] fix indentation: only duration change from 1000 to milliseconds --- inst/htmljs/animint.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 615ac19e0..f2a9b4f70 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -2008,18 +2008,18 @@ var animint = function (to_select, json_file) { .scale(Plots[p_name]["scales"][panel_i][axes]) .orient(orientation) .tickValues(tick_vals); - // update existing axis - var xyaxis_sel = element.select("#"+viz_id+"_"+p_name).select("."+axes+"axis_"+panel_i); - // Fix for issue #276: use selector's duration instead of hardcoded 1000ms - var milliseconds = 0; - if(Selectors.hasOwnProperty(v_name) && - Selectors[v_name].hasOwnProperty("duration")){ - milliseconds = Selectors[v_name].duration; - } - var xyaxis_g = xyaxis_sel - .transition() - .duration(milliseconds) - .call(xyaxis); + // update existing axis + var xyaxis_sel = element.select("#"+viz_id+"_"+p_name).select("."+axes+"axis_"+panel_i); + // Fix for issue #276: use selector's duration instead of hardcoded 1000ms + var milliseconds = 0; + if(Selectors.hasOwnProperty(v_name) && + Selectors[v_name].hasOwnProperty("duration")){ + milliseconds = Selectors[v_name].duration; + } + var xyaxis_g = xyaxis_sel + .transition() + .duration(milliseconds) + .call(xyaxis); // Fix for issue #273: preserve axis text styling after update apply_axis_text_styles(xyaxis_sel, axes, Plots[p_name]); } From 65843c23fccf24f2d2ad6e55dcb6ee662883eabd Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Thu, 4 Dec 2025 21:54:41 +0530 Subject: [PATCH 16/21] Fix #276: update_axes uses selector duration and correct plot_id selector - Pass v_name parameter to update_axes() to access selector duration - Use selector's duration instead of hardcoded 1000ms - Fix selector to use Plots[p_name].plot_id instead of manual construction - Add null check for v_name before accessing Selectors --- inst/htmljs/animint.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index f2a9b4f70..c1d72c854 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -2009,11 +2009,9 @@ var animint = function (to_select, json_file) { .orient(orientation) .tickValues(tick_vals); // update existing axis - var xyaxis_sel = element.select("#"+viz_id+"_"+p_name).select("."+axes+"axis_"+panel_i); - // Fix for issue #276: use selector's duration instead of hardcoded 1000ms + var xyaxis_sel = element.select("#"+Plots[p_name].plot_id).select("."+axes+"axis_"+panel_i); var milliseconds = 0; - if(Selectors.hasOwnProperty(v_name) && - Selectors[v_name].hasOwnProperty("duration")){ + if(v_name && Selectors.hasOwnProperty(v_name) && Selectors[v_name].hasOwnProperty("duration")){ milliseconds = Selectors[v_name].duration; } var xyaxis_g = xyaxis_sel @@ -2027,7 +2025,7 @@ var animint = function (to_select, json_file) { // Update major/minor grids once axes ticks have been updated function update_grids(p_name, axes, panel_i, grid_vals, scales){ // Select panel to update - var bgr = element.select("#"+viz_id+"_"+p_name).select(".bgr"+panel_i); + var bgr = element.select("#"+Plots[p_name].plot_id).select(".bgr"+panel_i); // Update major and minor grid lines ["minor", "major"].forEach(function(grid_class, j){ var lines = bgr.select(".grid_"+grid_class).select("."+axes); From 83b57c823cd2ba7f998a4317e89e9ac201dcd429 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Thu, 4 Dec 2025 22:24:13 +0530 Subject: [PATCH 17/21] Fix #276: update_axes uses selector duration and correct plot_id selector - Pass v_name parameter to update_axes() to access selector duration - Use selector's duration instead of hardcoded 1000ms - Fix selector to use Plots[p_name].plot_id instead of manual construction - Add null check for v_name before accessing Selectors - Fix test-compiler-ghpages.R to exclude common chunk TSV files from count --- tests/testthat/test-compiler-ghpages.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-compiler-ghpages.R b/tests/testthat/test-compiler-ghpages.R index 202643c24..df8c2f512 100644 --- a/tests/testthat/test-compiler-ghpages.R +++ b/tests/testthat/test-compiler-ghpages.R @@ -22,7 +22,7 @@ test_that("error for viz with no source", { }, "plot.list does not contain option named source, which is required by animint2pages") }) -get_tsv <- function(L)Sys.glob(file.path(L$local_clone, "*tsv")) +get_tsv <- function(L)Sys.glob(file.path(L$local_clone, "*chunk[0-9]*.tsv")) # exclude common tsv expect_Capture <- function(L){ expect_gt(file.size(file.path(L$local_clone,"Capture.PNG")), 0) } From fb218b74defbc8c786b05681c805341c7b40a922 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Fri, 5 Dec 2025 08:51:33 +0530 Subject: [PATCH 18/21] Add safety check for plot_id in update_axes and update_grids --- inst/htmljs/animint.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index c0f4b809c..c7fd443f4 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -2009,7 +2009,8 @@ var animint = function (to_select, json_file) { .orient(orientation) .tickValues(tick_vals); // update existing axis - var xyaxis_sel = element.select("#"+Plots[p_name].plot_id).select("."+axes+"axis_"+panel_i); + var plot_id = Plots[p_name] && Plots[p_name].plot_id ? Plots[p_name].plot_id : ("plot_"+p_name); + var xyaxis_sel = element.select("#"+plot_id).select("."+axes+"axis_"+panel_i); var milliseconds = 0; if(v_name && Selectors.hasOwnProperty(v_name) && Selectors[v_name].hasOwnProperty("duration")){ milliseconds = Selectors[v_name].duration; @@ -2025,7 +2026,8 @@ var animint = function (to_select, json_file) { // Update major/minor grids once axes ticks have been updated function update_grids(p_name, axes, panel_i, grid_vals, scales){ // Select panel to update - var bgr = element.select("#"+Plots[p_name].plot_id).select(".bgr"+panel_i); + var plot_id = Plots[p_name] && Plots[p_name].plot_id ? Plots[p_name].plot_id : ("plot_"+p_name); + var bgr = element.select("#"+plot_id).select(".bgr"+panel_i); // Update major and minor grid lines ["minor", "major"].forEach(function(grid_class, j){ var lines = bgr.select(".grid_"+grid_class).select("."+axes); From 1d3343a31969018ef6488d6fdefd7021bca90e7c Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Fri, 5 Dec 2025 09:50:12 +0530 Subject: [PATCH 19/21] Add safety checks for empty selectors array in initialization --- inst/htmljs/animint.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index c7fd443f4..47771480d 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -1964,7 +1964,7 @@ var animint = function (to_select, json_file) { // We update the current selection of the plot every time // and use it to index the correct domain var curr_select = axis_domains[xyaxis].curr_select; - if(axis_domains[xyaxis].selectors.indexOf(v_name) > -1){ + if(v_name && axis_domains[xyaxis].selectors.indexOf(v_name) > -1){ curr_select[v_name] = value; var str = use_panel+"."; for(selec in curr_select){ @@ -2344,8 +2344,10 @@ var animint = function (to_select, json_file) { if(!isArray(selectors)){ selectors = [selectors]; } - update_scales(p_name, xy, selectors[0], - response.selectors[selectors[0]].selected); + if(selectors.length > 0 && selectors[0] && response.selectors.hasOwnProperty(selectors[0])){ + update_scales(p_name, xy, selectors[0], + response.selectors[selectors[0]].selected); + } } } } From f6dbf4def42c47e46fe2102750483e7f03fe126c Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Wed, 10 Dec 2025 18:31:40 +0530 Subject: [PATCH 20/21] Revert unrelated changes, keep only duration fix for #276 - Reverted plot_id changes (not needed for this fix) - Reverted get_tsv change (unrelated to this PR) - Restored window.location.hash code (belongs to PR#282) - Keep only: pass v_name to update_axes, use selector duration --- inst/htmljs/animint.js | 61 +++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 47771480d..99352d24a 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -1964,7 +1964,7 @@ var animint = function (to_select, json_file) { // We update the current selection of the plot every time // and use it to index the correct domain var curr_select = axis_domains[xyaxis].curr_select; - if(v_name && axis_domains[xyaxis].selectors.indexOf(v_name) > -1){ + if(axis_domains[xyaxis].selectors.indexOf(v_name) > -1){ curr_select[v_name] = value; var str = use_panel+"."; for(selec in curr_select){ @@ -2009,8 +2009,7 @@ var animint = function (to_select, json_file) { .orient(orientation) .tickValues(tick_vals); // update existing axis - var plot_id = Plots[p_name] && Plots[p_name].plot_id ? Plots[p_name].plot_id : ("plot_"+p_name); - var xyaxis_sel = element.select("#"+plot_id).select("."+axes+"axis_"+panel_i); + var xyaxis_sel = element.select("#"+viz_id+"_"+p_name).select("."+axes+"axis_"+panel_i); var milliseconds = 0; if(v_name && Selectors.hasOwnProperty(v_name) && Selectors[v_name].hasOwnProperty("duration")){ milliseconds = Selectors[v_name].duration; @@ -2026,8 +2025,7 @@ var animint = function (to_select, json_file) { // Update major/minor grids once axes ticks have been updated function update_grids(p_name, axes, panel_i, grid_vals, scales){ // Select panel to update - var plot_id = Plots[p_name] && Plots[p_name].plot_id ? Plots[p_name].plot_id : ("plot_"+p_name); - var bgr = element.select("#"+plot_id).select(".bgr"+panel_i); + var bgr = element.select("#"+viz_id+"_"+p_name).select(".bgr"+panel_i); // Update major and minor grid lines ["minor", "major"].forEach(function(grid_class, j){ var lines = bgr.select(".grid_"+grid_class).select("."+axes); @@ -2344,10 +2342,8 @@ var animint = function (to_select, json_file) { if(!isArray(selectors)){ selectors = [selectors]; } - if(selectors.length > 0 && selectors[0] && response.selectors.hasOwnProperty(selectors[0])){ - update_scales(p_name, xy, selectors[0], - response.selectors[selectors[0]].selected); - } + update_scales(p_name, xy, selectors[0], + response.selectors[selectors[0]].selected); } } } @@ -2758,5 +2754,52 @@ var animint = function (to_select, json_file) { status_array=status_array.slice(1) return status_array.every(function(elem){ return elem === "displayed"}); } + if(window.location.hash) { + var fragment=window.location.hash; + fragment=fragment.slice(1); + fragment=decodeURI(fragment) + var frag_array=fragment.split(/(.*?})/); + frag_array=frag_array.filter(function(x){ return x!=""}) + frag_array.forEach(function(selector_string){ + var selector_hash=selector_string.split("="); + var selector_nam=selector_hash[0]; + var selector_values=selector_hash[1]; + var re = /\{(.*?)\}/; + selector_values = re.exec(selector_values)[1]; + var array_values = selector_values.split(','); + if(Selectors.hasOwnProperty(selector_nam)){ + var s_info = Selectors[selector_nam] + if(s_info.type=="single"){//TODO fix + array_values.forEach(function(element) { + wait_until_then(100, check_func, update_selector,selector_nam,element) + if(response.time)Animation.pause(true) + }); + }else{ + var old_selections = Selectors[selector_nam].selected; + // the levels that need to have selections turned on + array_values + .filter(function(n) { + return old_selections.indexOf(n) == -1; + }) + .forEach(function(element) { + wait_until_then(100, check_func, update_selector,selector_nam,element) + if(response.time){ + Animation.pause(true) + } + }); + old_selections + .filter(function(n) { + return array_values.indexOf(n) == -1; + }) + .forEach(function(element) { + wait_until_then(100, check_func, update_selector,selector_nam,element) + if(response.time){ + Animation.pause(true) + } + }); + }//if(single) else multiple selection + }//if(Selectors.hasOwnProperty(selector_nam)) + })//frag_array.forEach + }//if(window.location.hash) }); }; From 047cb030d817f9a39751a75c76a19759eed72358 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Fri, 19 Dec 2025 20:26:23 +0530 Subject: [PATCH 21/21] - Removed hash parsing code from animint.js - Revert test-compiler-ghpages.R to master - Keep only duration fix changes --- inst/htmljs/animint.js | 47 -------------------------- tests/testthat/test-compiler-ghpages.R | 2 +- 2 files changed, 1 insertion(+), 48 deletions(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 99352d24a..bfcc4b07f 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -2754,52 +2754,5 @@ var animint = function (to_select, json_file) { status_array=status_array.slice(1) return status_array.every(function(elem){ return elem === "displayed"}); } - if(window.location.hash) { - var fragment=window.location.hash; - fragment=fragment.slice(1); - fragment=decodeURI(fragment) - var frag_array=fragment.split(/(.*?})/); - frag_array=frag_array.filter(function(x){ return x!=""}) - frag_array.forEach(function(selector_string){ - var selector_hash=selector_string.split("="); - var selector_nam=selector_hash[0]; - var selector_values=selector_hash[1]; - var re = /\{(.*?)\}/; - selector_values = re.exec(selector_values)[1]; - var array_values = selector_values.split(','); - if(Selectors.hasOwnProperty(selector_nam)){ - var s_info = Selectors[selector_nam] - if(s_info.type=="single"){//TODO fix - array_values.forEach(function(element) { - wait_until_then(100, check_func, update_selector,selector_nam,element) - if(response.time)Animation.pause(true) - }); - }else{ - var old_selections = Selectors[selector_nam].selected; - // the levels that need to have selections turned on - array_values - .filter(function(n) { - return old_selections.indexOf(n) == -1; - }) - .forEach(function(element) { - wait_until_then(100, check_func, update_selector,selector_nam,element) - if(response.time){ - Animation.pause(true) - } - }); - old_selections - .filter(function(n) { - return array_values.indexOf(n) == -1; - }) - .forEach(function(element) { - wait_until_then(100, check_func, update_selector,selector_nam,element) - if(response.time){ - Animation.pause(true) - } - }); - }//if(single) else multiple selection - }//if(Selectors.hasOwnProperty(selector_nam)) - })//frag_array.forEach - }//if(window.location.hash) }); }; diff --git a/tests/testthat/test-compiler-ghpages.R b/tests/testthat/test-compiler-ghpages.R index df8c2f512..202643c24 100644 --- a/tests/testthat/test-compiler-ghpages.R +++ b/tests/testthat/test-compiler-ghpages.R @@ -22,7 +22,7 @@ test_that("error for viz with no source", { }, "plot.list does not contain option named source, which is required by animint2pages") }) -get_tsv <- function(L)Sys.glob(file.path(L$local_clone, "*chunk[0-9]*.tsv")) # exclude common tsv +get_tsv <- function(L)Sys.glob(file.path(L$local_clone, "*tsv")) expect_Capture <- function(L){ expect_gt(file.size(file.path(L$local_clone,"Capture.PNG")), 0) }