Skip to content

FIREFLY-2103: Fix reverse axis with limits not working - #2036

Merged
jaladh-singhal merged 1 commit into
devfrom
FIREFLY-2103-reverse-axis-bug
Oct 7, 2026
Merged

jaladh-singhal merged 1 commit into
devfrom
FIREFLY-2103-reverse-axis-bug

Conversation

@jaladh-singhal

Copy link
Copy Markdown
Member

Fixes FIREFLY-2103

With Y (or X) Min/Max set in Chart Options, checking or unchecking "reverse" did nothing: the bounds were re-applied using the old layout range's direction instead of the requested one. See the first commit's diff for the fix.

The root issue: the __xoptions/__yoptions branch of evalChangesFromFields encoded the requested direction into a re-ordered range or autorange, and adjustAxesRange inferred it back. The second commit (most of the diff, separately revertable) replaces both with evalAxisRangeChanges in AxisRangeUtil.js, which decides the range from the dialog inputs directly. This also fixed a log axis losing autoscale on every Apply and a NaN range when switching to log with values ≤ 0.

Tests in AxisRange-test.js which were run both before and after the refactor.

Testing

https://firefly-2103-reverse-axis-bug.irsakubedev.ipac.caltech.edu/firefly/

  • Load any catalog (e.g. AllWISE cone search on m81, 100") -> Chart Options -> set Y Min/Max -> check "reverse" -> Apply: axis should reverse within the bounds; uncheck -> Apply: back to normal
  • Same with log on, and with the X axis
  • Change the Y column and Apply with/without reverse + bounds: direction should follow the checkbox
  • Regression: reverse/un-reverse without bounds, zoom then Apply an unrelated option (zoom kept), histogram and heatmap Chart Options

@jaladh-singhal jaladh-singhal added this to the 2026.4 milestone Oct 5, 2026
@jaladh-singhal
jaladh-singhal requested review from loitly and a balanced review from Copilot October 5, 2026 22:31
@jaladh-singhal jaladh-singhal self-assigned this Oct 5, 2026
@jaladh-singhal jaladh-singhal added bug Charts Anything related to charts labels Oct 5, 2026
@jaladh-singhal jaladh-singhal changed the title Firefly 2103 reverse axis bug FIREFLY-2103: Fix reverse axis with limits not working Oct 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

A reset with only one bound produces an invalid NaN range while disabling autorange.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Fixes axis reversal with explicit bounds and centralizes Plotly range handling.

Changes:

  • Adds shared axis range evaluation utilities.
  • Refactors chart options to use them.
  • Adds axis direction, bounds, reset, and log-scale tests.
File Description
BasicOptions.jsx Delegates axis range changes to the new utility.
AxisRangeUtil.js Implements range, reversal, reset, and log handling.
AxisRange-test.js Covers axis range behavior and regressions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +81 to +82
if (isLog && (min <= 0 || max <= 0)) return autoscale; // can't show 0 or below on a log scale
return {[rangeKey]: getRange(min, max, isLog, flip), [autorangeKey]: false};

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's a narrow edge case that pre-dates this PR (the old adjustAxesRange built the same [min, NaN] range hence the test codified it to assess the success of refactor). This only happens when one bound is set with no current range to fill the other end from, as in:

  • the axis column is changed and a single bound typed in the same Apply (although changing the column already clears both bounds)
  • a new chart is created with one bound

Both of these are extremely rare from user POV since it would require user to set one bound before seeing the new plotted data range.

Still, I fixed this in the latest commit since it's a harmless fix: it now falls back to autoscale in the requested direction instead of Plotly's arbitrary span (e.g. 69.05 to 690.5, x10 guess that plotly does)

@jonesmg

jonesmg commented Oct 5, 2026

Copy link
Copy Markdown
Screenshot 2026-10-05 at 4 44 40 PM This looks good to me. I successfully managed to tailor the axes for my uploaded catalogue.

@loitly loitly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested. The bug is fixed, and the refactored code is clean and easy to understand. Good to go.

FIREFLY-2103: fix reversing chart axis when min/max bounds are set

adjustAxesRange rebuilt the range from the user's bounds but took the axis direction from the old layout range, discarding the reverse/un-reverse just requested in the options dialog. Take the direction from the reverse option's changes (re-ordered range or autorange), falling back to the current layout only when the fields have no reverse option. Also simplify the range re-ordering and drop lodash reverse.

FIREFLY-2103: centralize chart axis range evaluation

Replace the two-pass axis range logic in evalChangesFromFields (reverse option reordering the range, then adjustAxesRange inferring direction back from it) with evalAxisRangeChanges in AxisRangeUtil.js, which decides range and autorange per axis directly from the requested reverse/log options, bounds, column-change reset and current range. Behavior is unchanged except: staying on log no longer rebuilds the range and turns off autoscale on every Apply, and switching to log with a current range reaching 0 or below falls back to autorange instead of a NaN range. Add AxisRange-test.js covering reverse, bounds, column change, log scale and callers without axis options.

FIREFLY-2103: autoscale when a single axis bound has nothing to fill the other from

With one Y/X bound and no current range to fill the other end from (axis column changed in the same Apply, or a new chart), the range was built with a NaN end, which Plotly drew as an arbitrary span (e.g. 69.05 to 690.5). Fall back to autoscale in the requested direction instead.
@jaladh-singhal
jaladh-singhal force-pushed the FIREFLY-2103-reverse-axis-bug branch from 2a496e5 to 4bd7230 Compare October 7, 2026 18:37
@jaladh-singhal
jaladh-singhal merged commit a375217 into dev Oct 7, 2026
2 checks passed
@jaladh-singhal
jaladh-singhal deleted the FIREFLY-2103-reverse-axis-bug branch October 7, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Charts Anything related to charts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants