Repository navigation
fix(line_chart): print years on the x axis instead of "2.0K" - #922
Open
executorrr86 wants to merge 1 commit into
Open
executorrr86 wants to merge 1 commit into
executorrr86 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LineChartlabels its x axis with evenly spaced fractions of the x range, formatted with the sameformatNumberas the y axis. With years, every tick reads "2.0K": a 1990–2020 or 1990–2024 chart shows2.0K 2.0K 2.0K 2.0K 2.0K 2.0K 2.0K. With small integer x values (0–5, two series) the ticks read0, 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
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 ofNaNfor an empty or one-value range.formatXTick(n, format): integers below 10 000 as is; everything else through the chart's existingformatNumber.LineChart.tsx: uses both for the vertical grid and its labels. The y axis is unchanged.Rendered,
main→ this PR (frame 90, two series)main2.0K×72.0K×7Vertical grid lines move with the ticks only in the changed rows.
Testing
npx tsc --noEmit: clean.pytest tests: 2922 passed, 17 skipped.tests/contracts/test_line_chart_x_axis_contract.pyruns the productionxTicks.tsin 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 onmainand is skipped when Remotion is not installed, so it does not run in the current CI job.Checklist
make test-contracts/make test) where applicable.🤖 Generated with Claude Code