Skip to content

feat: add manual Y-axis range controls with auto fallback#64

Merged
JavaZeroo merged 1 commit intomasterfrom
codex/add-manual-y-axis-range-setting
Apr 20, 2026
Merged

feat: add manual Y-axis range controls with auto fallback#64
JavaZeroo merged 1 commit intomasterfrom
codex/add-manual-y-axis-range-setting

Conversation

@JavaZeroo
Copy link
Copy Markdown
Owner

Motivation

  • Provide a way to manually lock the chart Y-axis while keeping the default automatic scaling behavior.
  • Allow partial manual overrides (only min or only max) and an easy way to revert to automatic scaling to avoid breaking existing workflows.

Description

  • Added global yRange state in App and passed it into RegexControls and ChartContainer to expose UI and rendering hooks for Y-axis control.
  • Implemented a Y-axis panel in RegexControls with min/max inputs and an Auto button that clears manual bounds and returns to automatic scaling.
  • In ChartContainer added getFinalYScale which merges manual yRange with the computed automatic nice scale and safely falls back to auto when manual bounds are invalid; the same logic is applied to comparison charts.
  • Added i18n keys in public/locales/en/translation.json and public/locales/zh/translation.json for the new UI labels and hints.

Testing

  • Ran the test suite with npm test -- --run and all tests passed (13 test files, 57 tests).
  • Ran lint with npm run lint and it completed successfully with an existing unrelated warning about react-refresh/only-export-components.

Codex Task

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 20, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-04-20 06:52 UTC

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb15a04c1d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +187 to +189
const handleYRangeChange = (field, value) => {
const newRange = { ...yRange, [field]: value === '' ? undefined : Number(value) };
onYRangeChange(newRange);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve raw Y input text until value is complete

Parsing e.target.value with Number(...) on every keystroke drops intermediate numeric states ("-", "0.", etc.), so users cannot reliably type negative or decimal Y bounds; the control snaps to empty/integer values before the input is complete. This breaks manual range entry for common datasets (especially comparison/relative values) unless users paste the full number in one shot.

Useful? React with 👍 / 👎.

Comment on lines +408 to +412
return {
...autoScale,
min,
max
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Recompute Y tick step after overriding min/max

After applying manual bounds, this function keeps autoScale.step unchanged while replacing min/max, so the chart can use a step size that no longer matches the displayed range. In practice, widening bounds (for example from an auto range near 0..1 to a manual max in the thousands) can produce extremely dense ticks and hurt chart readability/performance.

Useful? React with 👍 / 👎.

@JavaZeroo JavaZeroo merged commit 62f87b8 into master Apr 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant