Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

stats: keep the e1RM chart's points stable, and note where stackedValue stops

Duarte Santosfa879a8b40bd
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 3259df543..a34845995 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -241,7 +241,11 @@ h4.sec{
.lrow-c{color:var(--label);font-size:15px;flex:none;--icon-stroke:2.4}
.lrow-k{color:var(--acc);font-size:17px;flex:none;--icon-stroke:2.4}
.lrow.danger,.lrow.danger .lrow-t{color:var(--red)}
-/* The Stats exercise name gets its own line so long names cannot run into the title. */
+/* The Stats exercise name gets its own line so long names cannot run into the title.
+ Two columns only — label/value on the left, chevron on the right — so this is for rows
+ WITHOUT an icon. `.lrow-i` is not placed here; on a row that has one it would auto-place
+ into the grid and push the layout around. Give it a leading column before using this
+ anywhere else. */
.lrow.lrow-stack-value{
display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:auto auto;
}
diff --git a/frontend/src/views/Stats.jsx b/frontend/src/views/Stats.jsx
index a7de297b1..3622b7bf4 100644
--- a/frontend/src/views/Stats.jsx
+++ b/frontend/src/views/Stats.jsx
@@ -360,7 +360,15 @@ export default function Stats() {
}
// Estimated 1RM (issue #18) — only reps-mode training produces one, so cardio and timed
// work simply have no points and the toggle stays hidden.
- const e1Pts = curEx && curMode === 'reps' ? e1rmSeries(S, curEx) : []
+ // Both memoised on the same inputs, and it has to start at e1rmSeries: LineChart clears its
+ // hover whenever `points` changes identity, so a chart array rebuilt on every render made the
+ // tooltip vanish under your finger the moment anything else on this screen re-rendered.
+ // Memoising only the .map() would not have helped — its dependency was itself rebuilt each time.
+ const e1Pts = useMemo(
+ () => (curEx && curMode === 'reps' ? e1rmSeries(S, curEx) : []),
+ [S, curEx, curMode],
+ )
+ const e1ChartPts = useMemo(() => e1Pts.map(p => ({ t: p.t, y: p.y, d: p.d })), [e1Pts])
const e1Best = curEx && curMode === 'reps' ? best1RM(S, curEx) : null
const showE1 = e1Pts.length > 0
// Effort on this exercise, per session. It rides on the top-set curve as well as having a
@@ -426,7 +434,7 @@ export default function Stats() {
<div className="chart">
{onEff
? <LineChart points={effPts} h={150} unit={hd} color="var(--yellow)" invert={kind === 'rir'} />
- : <LineChart points={onE1 ? e1Pts.map(p => ({ t: p.t, y: p.y, d: p.d })) : topPts} h={150} unit={exUnit} color="var(--blue)" />}
+ : <LineChart points={onE1 ? e1ChartPts : topPts} h={150} unit={exUnit} color="var(--blue)" />}
</div>
<div style={{ marginTop: 8 }}>{exList.map((p, i) => <div key={i} className="row between small" style={{ padding: '6px 0', borderBottom: 'var(--hair) solid var(--sep)' }}>
<span className="muted">{fmtDate(p.d, true)}</span><span>{p.sets.map(s => setLabel(curEx, s, p.target)).join(' ')}</span></div>)}</div>