Skip to content

Conversation

@ANAMASGARD
Copy link
Contributor

Fixes #276

Problem

The update_axes() function in the JavaScript renderer was using a hardcoded transition duration of 1000ms, regardless of what duration was set for the selector triggering the axis update.

This meant that when a user specified duration=list(year=2000) for a year selector, clicking to change years would cause:

  • The data points to transition over 2000ms (correct)
  • The axes to transition over 1000ms (incorrect - looks janky)

Testing

Added test-renderer3-update-axes-duration.R which:

  • Creates a visualization with duration=list(year=2000)
  • Verifies that axis transitions take 2000ms by checking position at 1200ms
  • With the bug: transition completes in 1000ms, test fails
  • With the fix: transition takes 2000ms, test passes

This failing test committed first, then the fix in a upcoming commits .

@ANAMASGARD ANAMASGARD requested a review from tdhock November 20, 2025 16:20
- 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
Copy link
Collaborator

@tdhock tdhock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix test failures before asking for review

- 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
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.
Test now properly creates axis domains that change between years.
Copy link
Collaborator

@tdhock tdhock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please simplify

JavaScript: Use simple '|| 0' instead of multiple checks
Test: Check tick changes instead of axis transform positions
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.
@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.08%. Comparing base (68b074e) to head (1d3343a).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #277      +/-   ##
==========================================
+ Coverage   69.53%   73.08%   +3.55%     
==========================================
  Files         163      164       +1     
  Lines        6004     8766    +2762     
==========================================
+ Hits         4175     6407    +2232     
- Misses       1829     2359     +530     
Flag Coverage Δ
javascript 80.81% <100.00%> (?)
r 69.53% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ANAMASGARD ANAMASGARD requested a review from tdhock November 26, 2025 00:40
@ANAMASGARD
Copy link
Contributor Author

Sir @tdhock Can you please review this PR now and give your feedback is there anything I need to change .

@ANAMASGARD
Copy link
Contributor Author

Also Sir @tdhock I want to ask for the issue you raised
#278
is raising a new PR would be appropriate or I should make the changes in this PR only .

@ANAMASGARD
Copy link
Contributor Author

Replaced magic numbers with unequal() function using tolerance parameter, following the same pattern as [test-renderer3-update-axes.

@ANAMASGARD ANAMASGARD requested a review from tdhock November 28, 2025 03:21
@ANAMASGARD
Copy link
Contributor Author

I sincerely apologize Sir you are absolutely right I should have followed your previous feedback
THE THINGS I HAVE CHANGED THIS TIME

  • Replaced expect_true with expect_gt - a more specific assertion as you requested
  • Removed the 0.01 tolerance - we now simply check that the difference is greater than 0
  • Added a comment explaining why tick spacing changes (different cyl subsets have different mpg/disp ranges)
  • The test now directly asserts that the tick spacing changed (difference > 0) without any magic numbers or expect_true/expect_false.

@ANAMASGARD ANAMASGARD requested a review from tdhock November 28, 2025 15:27
@ANAMASGARD ANAMASGARD force-pushed the fix-update-axes-duration branch from 38b2082 to 8e9d103 Compare December 3, 2025 16:47
ANAMASGARD and others added 3 commits December 4, 2025 21:54
…ctor

- 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
…ctor

- 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
@ANAMASGARD ANAMASGARD requested a review from tdhock December 4, 2025 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update_axes duration is always 1000

3 participants