Skip to content

fix(price-chart): fit the day on a phone, and stop clipping the axis - #838

Merged
frahlg merged 1 commit into
masterfrom
price-chart-compact-on-a-phone
Aug 6, 2026
Merged

fix(price-chart): fit the day on a phone, and stop clipping the axis#838
frahlg merged 1 commit into
masterfrom
price-chart-compact-on-a-phone

Conversation

@frahlg

@frahlg frahlg commented Aug 6, 2026

Copy link
Copy Markdown
Member

Fredrik, testing on his own box: "elpriserna kan vara lite mer kompact den är väldigt lång (hög)".

Measured, not adjusted by eye

At a 375×812 viewport, the chart is 343 px wide on the Plan screen:

viewBox painted price block share of viewport
before 0 0 1000 720 246.96 px 461 px 57 %
after 0 0 1000 440 150.92 px 365 px 45 %

Only the phone height moves, and only when the chart is fed — the attribute that already means "the app supplied the data". The box's own dashboard is untouched. W stays 1000, so every font size and padding is in viewBox units and paints at exactly the pixel size it did before: nothing was shrunk to make room, and the app's font sizes still compare toEqual the dashboard's in the test.

The clipped axis label

At phone width the bottom y-axis figure rendered as .00 ö — the leading zero clipped by the SVG's left padding. It is a function of pad.l and the axis font size alone, so the dashboard did it too. The gutter is now measured from the longest label rather than guessed, which is why the tick block moved above the geometry: the gutter cannot be computed without the label strings, and the labels cannot be placed without the gutter.

Notes for review

  • This is the upstream half. srcfl/ftw-webapp vendors this file byte for byte and its digest guard will want re-recording against the merge commit.
  • The changeset's percentages were wrong when I found them — it claimed 49 % → 37 %. The 12-point delta was right; the levels were eight points low. Corrected to the measured figures.
  • Written by an agent that stalled before reporting, then read and verified end to end by another. Every number above was measured in a browser and cross-checked in jsdom from a different route.

🤖 Generated with Claude Code

Fredrik, on his own box: "elpriserna kan vara lite mer kompact den är väldigt
lång (hög)". Measured at 375 px, the chart took 57% of the viewport before the
timeline under it began.

The phone viewBox is now 440 tall instead of 720 when the chart is fed rather
than fetching — 247 px down to 151 px, 45% of the viewport. Keyed on the
existing `fed` attribute, so the box's own dashboard is untouched; W stays at
1000, so every font size and padding is in viewBox units and paints at exactly
the pixel size it did before. Nothing was shrunk to make room.

The left gutter is measured now rather than guessed. At phone width the bottom
y-axis label rendered as ".00 ö" with the leading zero clipped, which is a
function of the padding and the axis font size alone and so did it on the
dashboard too. The tick block moved above the geometry because the gutter
cannot be computed without the label strings.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@frahlg
frahlg merged commit f55eaa2 into master Aug 6, 2026
13 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 72615dac18

ℹ️ 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".

// lowers the bars' ceiling and changes the size of nothing else: the
// axis figures, the NOW pill and the peak markers all come out at the
// same pixel size they do at 720.
const H = small ? (this.hasAttribute("fed") ? 440 : 720) : 240;

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 Preserve enough height to separate y-axis labels

When a fed phone chart contains a narrow price spike—for example, two expensive slots in a 48-hour window—the mean is close to the minimum, and reducing plotH from 654 to 374 viewBox units moves those two tick baselines from about 25 units apart to about 14 while both retain a 27-unit font size. The mean and minimum labels therefore overlap for realistic spiky price series; add tick-collision handling or retain enough vertical plot height for these labels.

Useful? React with 👍 / 👎.

@frahlg
frahlg deleted the price-chart-compact-on-a-phone branch August 7, 2026 08:18
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