Skip to content

fix(line_chart): print years on the x axis instead of "2.0K" - #922

Open
executorrr86 wants to merge 1 commit into
OpenMontageInc:mainfrom
executorrr86:fix/line-chart-year-axis
Open

executorrr86 wants to merge 1 commit into
OpenMontageInc:mainfrom
executorrr86:fix/line-chart-year-axis

Conversation

@executorrr86

@executorrr86 executorrr86 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

LineChart labels its x axis with evenly spaced fractions of the x range, formatted with the same formatNumber as the y axis. With years, every tick reads "2.0K": a 1990–2020 or 1990–2024 chart shows 2.0K 2.0K 2.0K 2.0K 2.0K 2.0K 2.0K. With small integer x values (0–5, two series) the ticks read 0, 0.8, 1.7, 2.5, 3.3, 4.2, 5.

When every x is an integer, ticks are now rounded to integers, and integers below 10 000 print as they are. Spacing and tick count follow the same rule as before.

Related issue

None.

Changes

  • New charts/xTicks.ts:
    • pickXTicks(xs): the same evenly spaced ticks as before (min(points - 1, 6) intervals), rounded and de-duplicated when every x is an integer. It also returns a single tick instead of NaN for an empty or one-value range.
    • formatXTick(n, format): integers below 10 000 as is; everything else through the chart's existing formatNumber.
  • LineChart.tsx: uses both for the vertical grid and its labels. The y axis is unchanged.

Rendered, main → this PR (frame 90, two series)

x data main This PR
1990, 2000, 2010, 2020 2.0K ×7 1990, 1995 … 2020
1990–2024, 35 years 2.0K ×7 1990, 1996, 2001, 2007, 2013, 2018, 2024
0–5 0, 0.8, 1.7, 2.5, 3.3, 4.2, 5 0, 1, 2, 3, 4, 5
0, 1, 2, 5, 13, 30 (irregular) 0, 6 … 30 pixel-identical
0, 0.5, 1.25, 2, 3.5 (fractional) (unchanged) pixel-identical
0–3, one series (unchanged) pixel-identical

Vertical grid lines move with the ticks only in the changed rows.

Testing

  • npx tsc --noEmit: clean.
  • Full pytest tests: 2922 passed, 17 skipped.
  • tests/contracts/test_line_chart_x_axis_contract.py runs the production xTicks.ts in Node: integer, year, irregular, fractional and degenerate ranges, and the tick labels. It also renders a check (remotion still) that a 1990–2020 axis and a 1991–2021 axis no longer render the same labels. That check fails on main and is skipped when Remotion is not installed, so it does not run in the current CI job.

Checklist

  • The change is focused on a single logical concern.
  • I ran the relevant tests locally (make test-contracts / make test) where applicable.
  • I updated docs/README if behavior or usage changed. (No docs change needed.)
  • No unrelated files (build artifacts, local config) are included in the diff.

🤖 Generated with Claude Code

Ticks were evenly spaced fractions of the x range, formatted like y values, so a
1990-2024 axis read "2.0K" on every tick. When every x is an integer the ticks are
now rounded to integers, and integers below 10 000 print as is. Irregular and
fractional x data keep the same ticks as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant