Skip to content

Fix bar chart label placement (#1182) and config-page select crash#1224

Open
gskjold wants to merge 3 commits into
mainfrom
fix/chart-labels-and-config-crash
Open

Fix bar chart label placement (#1182) and config-page select crash#1224
gskjold wants to merge 3 commits into
mainfrom
fix/chart-labels-and-config-crash

Conversation

@gskjold

@gskjold gskjold commented Jun 25, 2026

Copy link
Copy Markdown
Member

Two UI fixes, verified on device (ESP32-S2).

1. Bar chart value-label placement (closes #1182)

Value labels could be drawn over a bar's edge or clipped at the chart baseline:

  • Minor graphic error #1182 – On the future-price chart, low-price bars (< ~0.20) had their white inside-label read past the baseline and get clipped by the SVG viewBox.
  • Day plot – Short bars' centered horizontal labels spilled over the bar's top/bottom edge (invisible white-on-white in light mode; floating onto gridlines in dark mode), and import/export labels for the same hour crowded the zero line.

Fix: the inline placement ternaries in BarChart.svelte are replaced with small pure helpers (impLabelY / impLabelOutside / expLabelY / expLabelOutside) that take the scale values as arguments, so Svelte still tracks reactivity. Rotated labels keep the existing clamped behaviour (the original #1182 fix); non-rotated (wide-bar) labels now sit flush to the bar's outer edge when they fit, and float just outside the bar — in the bar colour — when the bar is too short to contain the centered label. This pushes labels away from the zero line, fixing both the edge overflow and the crowding.

2. ReferenceError: el is not defined on the config page

Changing the price region/resolution/currency (or any) <select> on the configuration page threw ReferenceError: el is not defined and broke the form.

Cause: Svelte 5 compiled the UI-feature toggle loop's bind (bind:value={configuration.u[el.key]} inside {#each uiElements as el}) into an invalidate_inner_signals reference to the each-local el, and emitted that reference into every other bind that mutates configuration — at component scope, where el is undefined.

Fix: move the loop body into a small UiFeatureToggle child component so the each-local is never referenced in a bind path at the parent's scope.

Verification

Rendered the real components with live device data through a stubbed-fetch harness (headless Chrome screenshots):

  • Day plot: short-bar labels float cleanly above/below the bars; import/export labels separated at the zero line; no labels over edges.
  • Price chart, wide (non-rotated — what the 1520px device uses): Minor graphic error #1182 low-price labels sit at the bar top, no baseline clip.
  • Price chart, narrow (rotated): unchanged, no clip.
  • Config page: changing every select no longer throws; the 15 UI-feature toggles render and keep their bound values.
  • Confirmed working on device.

🤖 Generated with Claude Code

gskjold and others added 3 commits June 25, 2026 13:50
The positive (import/price) and negative (export) value labels could be
drawn over a bar's edge or clipped at the chart baseline:

- Issue #1182: on the future-price chart, low-price bars had their white
  inside-label read past the baseline and get clipped by the SVG viewBox.
- On the 24-hour day plot, short bars' centered horizontal labels spilled
  over the bar's top/bottom edge (invisible white-on-white in light mode,
  floating onto gridlines in dark mode), and import/export labels for the
  same hour crowded the zero line.

Replace the inline placement ternaries with small pure helpers
(impLabelY/impLabelOutside/expLabelY/expLabelOutside) that take the scale
values as arguments so Svelte still tracks reactivity. Rotated labels keep
the existing clamped behaviour; non-rotated (wide-bar) labels now sit flush
to the bar's outer edge when they fit and float just outside the bar, in
the bar colour, when the bar is too short to contain the centered label.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
On the configuration page, changing the price region/resolution/currency
(or any other) <select> threw `ReferenceError: el is not defined` and
broke the form. Svelte 5 compiled the UI-feature toggle loop's bind
(`bind:value={configuration.u[el.key]}` inside `{#each uiElements as el}`)
into an `invalidate_inner_signals` reference to the each-local `el`, and
emitted that reference into every other bind that mutates `configuration`
— at component scope, where `el` is undefined.

Move the loop body into a small UiFeatureToggle child component so the
each-local is never referenced in a bind path at the parent's scope.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Regenerate ui/dist for the bar-chart label placement and config-page
select fixes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🔧 PR Build Artifacts

Version: 7d5343b

All environments built successfully. Download the zip files:

Artifacts expire after 7 days. View workflow run

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.

Minor graphic error

1 participant