Skip to content

Sheets: a chart is drawn at the width it's shown at, so its labels stay 12 px on a phone - #1

Merged
jamescalam merged 2 commits into
mainfrom
sheets-216
Nov 15, 2026
Merged

jamescalam merged 2 commits into
mainfrom
sheets-216

Conversation

@jamescalam

Copy link
Copy Markdown
Contributor

A chart was an SVG drawn in a fixed 760×300 viewBox and scaled to its box. At 390 px wide the box is about 358 px, so the 12 px labels drew at about 5.8 px and the month names ran into each other. At 1280 it scaled up, and "May 2026" touched "Jun 2026".

What changed

  • The chart is drawn at the width it's shown at (at most 860 px), and drawn again when that width changes. Its text stays 12 px at every width.
  • Axes come from the engine's new chartAxes(o), which the tests call directly:
    • value steps are round (£0, £500, £1,000, £1,500), not quarters of the biggest bar;
    • month labels drop the year when the title names their one year ("Jan", not "Jan 2026");
    • labels sit in one row while they fit. After that, months and dates thin to every 2nd, 3rd… label. Names are cut to 12 characters and angled 45°, and thinned only when even angled ones can't all fit;
    • one series has no key when the title already names it.

Testing

  • node tests/run.js: 76 passed (5 new, on thinning, round steps, month labels and the key).
  • npx spacesheep skills lint: well-formed, 8 files, hash 80a3aa7b54bb.
  • At 390 px: chart text 12 px (was 5.8), no labels touch. At 1280 px: twelve month labels apart.

Worth a close look

  • The redraw on resize in renderCharts: it should fire only when the box's width changes, not on every layout pass.
  • chartAxes's thinning for names: angled labels are cut to 12 characters, so two names that share their first 12 can read alike.

jamescalam and others added 2 commits November 15, 2026 11:35
… reads a cell

=SUMPRODUCT(A1:T10000, ...) with 16 ranges of 200,000 cells read each
range before SUMPRODUCT ran. The budget charged each read, so it ended
in #CALC! only at the 16th range, after 3 million cell reads: about
2 s on a laptop, and over 3 s on CI's runners, where the hostile test
timed out. A person's sheet with such a formula froze for as long.

Now, before a formula is worked out, the engine adds up the cells of
every range it is sure to read (all of them, except the parts of IF,
IFERROR, IFNA and IFS past the first, which may never be worked out).
Each of those reads would be charged its cells anyway, so a total past
the budget ends in #CALC! at once, with no cell read. A highlight's test
gets the same check. refRange's span moves into refSpan, which both use.

Co-authored-by: Pointman <noreply@pointman.ai>
Co-authored-by: Claude <noreply@anthropic.com>
…ay 12 px on a phone

The chart was a 760-unit drawing scaled to its box, so at 390 px its text
drew at about 6 px and the month labels ran together; at 1280 it scaled
up and "May 2026" touched "Jun 2026".

Now the drawing is as wide as its box (at most 860 px) and is drawn
again when that width changes. Its axes come from the engine's new
chartAxes, which the tests call:
- value steps are round (£0, £500, £1,000, £1,500), not quarters of the
  biggest bar;
- month labels drop the year when the title names their one year;
- labels sit in a row while they fit; months and dates then thin to every
  2nd, 3rd... one, and names are cut to 12 characters and angled, thinned
  only when even angled ones can't all fit;
- one series has no key when the title names it.

Co-authored-by: Pointman <noreply@pointman.ai>
Co-authored-by: Claude <noreply@anthropic.com>
@jamescalam
jamescalam changed the base branch from main to sheets-222 November 15, 2026 03:39
@jamescalam
jamescalam changed the base branch from sheets-222 to main November 15, 2026 04:35
@jamescalam
jamescalam merged commit d9c7e4a into main Nov 15, 2026
1 check passed
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