Batteriespannungs-Diagramm: feste 170px-Höhe statt aspect-ratio, Y-Achse geklemmt

Die aspect-ratio-Lösung für die volle Spaltenbreite ließ auf großen Bildschirmen
die gesamte Koordinatenfläche mitwachsen - Achsenbeschriftungen (fester font-size
in SVG-Einheiten) wurden dadurch auf ~26px zu groß, das Diagramm unnötig hoch.
Zurück auf eine feste 170px-Höhe: der Y-Maßstab bleibt immer 1:1, nur die
X-Achse dehnt sich auf die volle Breite - normale Schriftgröße, kompaktes
Diagramm, trotzdem volle Spaltenbreite.

bvSkalaY()/y() klemmen jetzt auf [0,1] statt roh zu extrapolieren - ein Punkt
außerhalb von yMin/yMax (z. B. ein Ausreißer auf einer noch nicht aktualisierten
Instanz) zeichnet sich sonst weit außerhalb der Fläche und reißt die Linie über
den Rand hinaus, statt sichtbar am Achsenrand zu liegen.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-27 18:33:31 +02:00
parent b8e560e75b
commit cf57c5f1a5
7 changed files with 61 additions and 14 deletions
+33
View File
@@ -3234,6 +3234,39 @@ interact with there); `batterie.py` re-`py_compile`d clean after the floor chang
restart confirmed clean via log at every step (single `audi_dashboard` loader warning each time, no
duplicate-domain regression).
**Third follow-up (2026.8.27.5): a real regression from the `.1` width fix, plus a robustness gap, both
found from an owner screenshot of the wide-screen chart.** (1) **"Numbers are too large" / "reduce the
height"** - the `.1` fix (aspect-ratio matching the 320:170 viewBox so height scales with width) meant the
whole coordinate system, axis text included, scaled up together: at the full ~772px column width the SVG's
Y-scale grew to ~2.4×, so the `font-size="11"` axis labels rendered at ~26px and the chart itself grew to
~410px tall - both regressions from the same root cause, not two separate bugs. Reverted to a **fixed pixel
height** (`height:${BV_H}px` = 170px, dropping `aspect-ratio` entirely) with `width:100%` unchanged - the
Y-scale is now always exactly 1:1 regardless of container width, so axis text stays a normal ~11px and the
chart stays a compact, constant 170px tall on any screen; only the X-axis stretches to fill the column,
which is exactly the wide-and-short shape the owner asked for. companion-app's `Verlaufsdiagramm` never had
this bug (`.dm-diagramm` already used a fixed `height:120px` with no SVG-embedded text) - nothing to fix
there, confirmed by inspection.
(2) **"0V is being respected on the real instance - why isn't it ignored?"** - the screenshot showed a data
point plotted **below the axis's bottom edge**, past the 10V gridline, and a `0,0 V` SOC readout. Two
different things bundled in that one report: the underlying data point is almost certainly a pre-`.4`
reading (the same class of stale-data issue as `.2` item 1 above) sitting in the **real instance's**
`batteriespannung.jsonl` from before that instance was updated to run the raised `SPANNUNG_MIN_V=10.0` floor
- this session only ever touched `audi_ha_test`, never the owner's real instance, so nothing here confirms
the real instance is even running `.4`/`.5` yet (needs the self-update button + restart, or `install.ps1`,
plus a swipe-delete of the offending day exactly like `.2` item 1). Separately, and fixed here regardless of
that: **`bvSkalaY()` never clamped its output** - a point outside `[yMin, yMax]` (whatever the reason: a
stale reading, a not-yet-updated instance, a future edge case) extrapolated linearly past the plot area
instead of pinning to the axis edge, which is what actually drew the line running off the bottom of the
chart in the screenshot. Clamped the fraction to `[0, 1]` before scaling, in both codebases (companion-app's
equivalent `y()` in `Verlaufsdiagramm` got the identical clamp, for the same reason - it had no text-scaling
bug but shared this gap). This is a defensive rendering fix, not a data fix - it stops a bad point from
visually breaking the chart, but the owner's real instance still needs updating and the stale entry still
needs deleting for the *readout* (SOC/current-value tiles) to stop showing 0V too. Verified live: SVG
measured 736×170px at a 1400px viewport (Y-scale exactly `1`), axis label `getComputedStyle` font-size
`11px`, screenshot confirmed normal-sized labels and a compact chart using the full column. companion-app:
`tsc --noEmit` clean. Manifest bumped to `2026.8.27.5`, `npm run ota` rerun, `audi_ha_test` restart confirmed
clean via log.
---
## Working conventions (observed — keep them)
+6 -1
View File
@@ -162,7 +162,12 @@ function Verlaufsdiagramm({ werte }: { werte: Tageswert[] }) {
const x = (i: number) =>
rand + (i / Math.max(1, werte.length - 1)) * (breite - 2 * rand)
const y = (v: number) => hoehe - rand - ((v - kleinster) / spanne) * (hoehe - 2 * rand)
// Anteil auf [0,1] geklemmt statt roh extrapoliert - ein Ausreißer außerhalb
// von kleinster/groesster zeichnet sich sonst weit außerhalb der Fläche.
const y = (v: number) => {
const anteil = Math.max(0, Math.min(1, (v - kleinster) / spanne))
return hoehe - rand - anteil * (hoehe - 2 * rand)
}
const linie = (auswahl: (t: Tageswert) => number | null) =>
werte
@@ -1 +1 @@
{"version":"2026.8.27.3","sha256":"b99d93aae2ff58e58107e04f25edfb590e159f55414c11ba4645e82a36f09108","bytes":235508,"gebaut":"2026-08-27T16:01:36Z"}
{"version":"2026.8.27.5","sha256":"8d63b052bdcf4cf2eabd5a01f525fc25c4ab8eea30327dc3b8cbd0db2feb05ed","bytes":235510,"gebaut":"2026-08-27T16:30:48Z"}
@@ -1806,7 +1806,7 @@ function vBatterieverlauf() {
</div>
${genug ? `
<div id="bvChart" style="margin-top:14px;touch-action:none;position:relative">
<svg id="bvSvg" viewBox="0 0 ${BV_W} ${BV_H}" preserveAspectRatio="none" style="width:100%;aspect-ratio:${BV_W}/${BV_H};display:block"></svg>
<svg id="bvSvg" viewBox="0 0 ${BV_W} ${BV_H}" preserveAspectRatio="none" style="width:100%;height:${BV_H}px;display:block"></svg>
</div>
<div style="display:flex;justify-content:space-between;align-items:center;margin-top:10px">
<span class="label" id="bvRange" style="margin-top:0"></span>
@@ -1872,7 +1872,15 @@ function vBatterieliste() {
}
function bvSkalaX(t) { return BV_ML + ((t - bvDomain[0]) / (bvDomain[1] - bvDomain[0])) * (BV_W - BV_ML - BV_MR); }
function bvSkalaY(v, yMin, yMax) { return BV_H - BV_MB - ((v - yMin) / (yMax - yMin)) * (BV_H - BV_MT - BV_MB); }
/* Auf [0,1] geklemmter Anteil statt roher Extrapolation - ein Punkt außerhalb
von yMin/yMax (z. B. ein Ausreißer, der die Plausibilitätsgrenze auf einer
noch nicht aktualisierten Instanz umgangen hat) zeichnet sich sonst weit
außerhalb der sichtbaren Fläche und reißt die Linie unkontrolliert nach
unten/oben aus - geklemmt liegt er sichtbar am oberen/unteren Rand. */
function bvSkalaY(v, yMin, yMax) {
const anteil = Math.max(0, Math.min(1, (v - yMin) / (yMax - yMin)));
return BV_H - BV_MB - anteil * (BV_H - BV_MT - BV_MB);
}
function bvDomainKlemmen(domain) {
let [a, b] = domain;
const volle = bvVollDomain[1] - bvVollDomain[0];
@@ -335,15 +335,16 @@ main#view{--seitenrand:16px;padding:0 var(--seitenrand) 30px;scroll-behavior:smo
.setup-popup,.sdpopup,.sheet,.beleg-popup{max-width:560px;margin-left:auto;margin-right:auto}
.standortmenu{max-width:640px;margin-left:auto;margin-right:auto}
/* Batteriespannungs-Diagramm ist auf BV_W=320 SVG-Einheiten gezeichnet
(audi-dashboard-app.js), vorher mit fester Hoehe von 170px bei
preserveAspectRatio="none" - bei voller Spaltenbreite (772px
Inhaltsbreite: 860 - 2*44px Seitenrand) zog das Diagramm zu einem extrem
breiten, flachen Band auseinander, gedeckelt mit max-width:400px (macht
es dafuer auf grossen Bildschirmen unnoetig klein). Das SVG traegt jetzt
ein aspect-ratio passend zum viewBox-Verhaeltnis (320/170), wodurch die
Hoehe mit der Breite mitwaechst - das Diagramm darf deshalb die volle
Spaltenbreite nutzen, ohne wieder zu verzerren. */
/* Batteriespannungs-Diagramm: die Hoehe bleibt bewusst bei den festen 170px
aus BV_H (audi-dashboard-app.js), nur die Breite nutzt die volle
Spaltenbreite (772px: 860 - 2*44px Seitenrand). Ein Versuch, die Hoehe per
aspect-ratio mit der Breite mitwachsen zu lassen (~410px bei voller
Spalte), liess auch die SVG-Beschriftungen (fester font-size in
Zeichen-Einheiten) auf ~26px mitwachsen und das Diagramm unnoetig hoch
werden - vom Nutzer als "Zahlen zu gross"/"Hoehe reduzieren" gemeldet.
Bei fester Hoehe bleibt der Y-Massstab immer 1:1 (170 Einheiten = 170px),
also bleiben Beschriftungen normal gross; nur die X-Achse dehnt sich -
genau das breite, flache Band, das der Nutzer hier ausdruecklich wollte. */
}
/* Fahrzeugbild randlos wie in einer Fahrzeug-App: der Platzhalter bleibt
@@ -1,7 +1,7 @@
{
"domain": "audi_dashboard",
"name": "Audi Dashboard",
"version": "2026.8.27.4",
"version": "2026.8.27.5",
"documentation": "https://gitea.nothaft.cloud/paul/audi-app/src/branch/main/README.md",
"issue_tracker": "https://gitea.nothaft.cloud/paul/audi-app/issues",
"codeowners": ["@paul"],