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.

feat(stats): measure lifts against body weight in Exercise progress and Exercise history (#729)

radu78128c944e55cd4
diff --git a/docs/FAQ.md b/docs/FAQ.md
index 2422e051e..5247118c9 100644
--- a/docs/FAQ.md
+++ b/docs/FAQ.md
@@ -229,6 +229,16 @@ phone has seen. One case it gets wrong on purpose: if the old phone sets somethi
what it was before, after another device changed it, the other device's change wins. Once every
device is updated, nobody has to guess.
+### How does the Bodyweight chart in Stats count my body weight?
+
+Under Exercise progress, Bodyweight shows the heaviest set (or the estimated 1RM) as a percentage of
+your body weight at the time (an exercise's History sheet has the same tab, on the estimated 1RM), so it only rises when you got stronger for your size. For bodyweight
+and assisted exercises your body weight is part of the load: a weighted pull-up counts body weight
+plus the added weight, an assisted machine body weight minus the assistance. Dumbbells and kettlebells
+count both together, whichever way the exercise's weight is set to be read (one-arm work counts one). The body weight comes
+from the weight you logged with the workout, or from your weigh-ins (nearest within 30 days). A
+workout with neither is left out, and the chart only appears with at least two workouts.
+
### I'm moving from another app. Can I bring my history?
FitNotes, Strong and Hevy work out of the box, Apple Health for body weight, and any CSV with a date,
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js
index f2422b5dd..7d20f557d 100644
--- a/frontend/src/lib/pt-br-locale.test.js
+++ b/frontend/src/lib/pt-br-locale.test.js
@@ -41,7 +41,7 @@ describe('Brazilian Portuguese locale', () => {
// has to be taught is a number nobody reads. What the numbers stood for is asserted above.
// If the hash fails, review the changed keys and wording before accepting a new one. From
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
- expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('be751d61beddb8ba099effdfc15b9e416f8b74556838c9c03be644ca276905d2')
+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('efa25b6f0f05522fc588701686b7d88ff745dc2a6d7690f81d814a900c5b9cbf')
})
// pt-PT labelled Unpair 'Desfazer': Undo, in Portuguese (it is pt-BR's Undo), on the button that
diff --git a/frontend/src/lib/relative-strength.js b/frontend/src/lib/relative-strength.js
new file mode 100644
index 000000000..d9584e52c
--- /dev/null
+++ b/frontend/src/lib/relative-strength.js
@@ -0,0 +1,96 @@
+/* Relative strength: an exercise's progress against body weight over time.
+ *
+ * Each workout becomes one point: (best effective load) ÷ (body weight then), drawn as "×BW".
+ * "Effective load" is what was actually moved, so one chart covers every kind of exercise:
+ * normal lift logged weight
+ * bodyweight, loaded body weight + the added weight (weighted pull-up, belted dip)
+ * bodyweight, bare body weight
+ * assisted machine body weight − the assistance (less help = a higher ratio)
+ * The best is taken either as an estimated 1RM ('e1rm') or as the heaviest set ('top').
+ * Pure, so the chart and the tests read the same thing. */
+import { isAssisted } from './exercises.js'
+import { entriesForExercise, metricRowsForEntry, workoutAt } from './history.js'
+import { onLifter } from './structuralBalance.js'
+import { isSideSet } from './workout-model.js'
+import { estimate1RM, formulaOf } from './onerm.js'
+import { currentDbLoad, workoutAs, isBellEx } from './dumbbells.js'
+
+const DAY = 86400000
+// A weigh-in further than this from a workout says nothing about that day.
+export const BW_MAX_GAP_DAYS = 30
+
+const timeOf = b => Number(b?.t) || new Date(b?.d).getTime()
+
+/** Body weight at time `t`, from the weigh-in log: interpolated between the two weigh-ins around
+ * it, or the nearest one when `t` is outside the log. Null when the nearest weigh-in is more
+ * than `maxGapDays` away, or there is none. */
+export function bodyweightAt(log, t, maxGapDays = BW_MAX_GAP_DAYS) {
+ const pts = (log || [])
+ .map(b => ({ t: timeOf(b), w: Number(b?.w) }))
+ .filter(b => Number.isFinite(b.t) && Number.isFinite(b.w) && b.w > 0)
+ .sort((a, b) => a.t - b.t)
+ if (!pts.length || !Number.isFinite(t)) return null
+ let before = null, after = null
+ for (const p of pts) {
+ if (p.t <= t) before = p
+ else { after = p; break }
+ }
+ const gap = p => (p ? Math.abs(p.t - t) : Infinity)
+ const limit = maxGapDays * DAY
+ if (before && after) {
+ if (Math.min(gap(before), gap(after)) > limit) return null
+ return before.w + (after.w - before.w) * ((t - before.t) / (after.t - before.t))
+ }
+ const near = before || after
+ return gap(near) <= limit ? near.w : null
+}
+
+/** The weight actually moved by one set, or 0 when it cannot be told (assistance above body weight). */
+export function effectiveLoad({ assisted, bodyweight }, w, bw) {
+ const load = Number(w) || 0
+ if (assisted) return Math.max(0, bw - load)
+ if (bodyweight) return bw + load
+ return load
+}
+
+const doneSides = set => [set.sides.L, set.sides.R].filter(side => side?.done === true)
+
+/** One point per workout: [{ t, d, y, bw, load, note? }], chronological. `y` is the ratio to body
+ * weight; `load` the effective load it was made from; `assisted` that the best set was on an
+ * assistance machine (as the entry says, so a routine's own setting counts), where there is no
+ * 1RM and `y` is always the heaviest set. `basis` is 'e1rm' or 'top'. A workout with
+ * no weigh-in near it, or no set the basis can use, has no point. */
+export function relativeSeries(S, exId, { basis = 'e1rm', formula = formulaOf(S) } = {}) {
+ const out = []
+ // Dumbbells and kettlebells are read as the total of both bells, whatever the exercise is set to
+ // for its own display: body weight is one number, so the load it is divided into must be the
+ // whole load, not the weight of one bell. One-arm work has one bell and so no conversion.
+ const as = isBellEx(exId) ? 'total' : currentDbLoad(S, exId)
+ for (const workout of S.workouts || []) {
+ const t = workoutAt(workout)
+ // The weigh-in the workout was logged at wins; the log fills in for older workouts.
+ const logged = Number(workout.bw)
+ const bw = logged > 0 ? logged : bodyweightAt(S.bodyweight, t)
+ if (!(bw > 0)) continue
+ let best = 0, viaHelp = false
+ for (const entry of entriesForExercise(workoutAs(workout, exId, as), exId)) {
+ // The same reading as the structural balance (lib/structuralBalance.js onLifter): the entry's
+ // own flag, else the exercise, and belt-and-vest pull-ups and dips, whose logged weight is
+ // the plate on the belt, so body weight is part of the load there too.
+ const kind = { assisted: isAssisted(entry), bodyweight: onLifter(entry) }
+ for (const row of metricRowsForEntry(entry, 'reps')) {
+ for (const set of isSideSet(row) ? doneSides(row) : [row]) {
+ const load = effectiveLoad(kind, set.w, bw)
+ if (load <= 0) continue
+ // No one-rep max on an assistance machine (issue #232): the load is partly the machine's,
+ // so extrapolating 9 reps at 78 kg to a "102 kg 1RM" says you out-lift your own body
+ // weight on a machine that is still helping you. It is always the heaviest set there.
+ const y = basis === 'top' || kind.assisted ? load : estimate1RM(load, set.r, formula, set.rir ?? null)
+ if (y > best) { best = y; viaHelp = kind.assisted }
+ }
+ }
+ }
+ if (best > 0) out.push({ t, d: workout.d, y: best / bw, load: best, bw, assisted: viaHelp })
+ }
+ return out
+}
diff --git a/frontend/src/lib/relative-strength.test.js b/frontend/src/lib/relative-strength.test.js
new file mode 100644
index 000000000..9060b9e5b
--- /dev/null
+++ b/frontend/src/lib/relative-strength.test.js
@@ -0,0 +1,198 @@
+import { describe, expect, it } from 'vitest'
+import { bodyweightAt, effectiveLoad, relativeSeries, BW_MAX_GAP_DAYS } from './relative-strength.js'
+
+const DAY = 86400000
+const LIFT = '0025'
+const done = (w, r, extra = {}) => ({ w, r, done: true, ...extra })
+const workout = (t, entries, bw) => ({ start: t, d: new Date(t).toISOString().slice(0, 10), entries, ...(bw ? { bw } : {}) })
+const entry = (sets, extra = {}) => ({ id: LIFT, sets, ...extra })
+const state = (workouts, bodyweight = []) => ({ workouts, bodyweight, unit: 'kg' })
+
+describe('bodyweightAt', () => {
+ const T0 = 100 * DAY
+ const log = [{ t: T0, w: 90 }, { t: T0 + 10 * DAY, w: 80 }]
+
+ it('interpolates between the weigh-ins around a time', () => {
+ expect(bodyweightAt(log, T0 + 5 * DAY)).toBeCloseTo(85)
+ })
+
+ it('uses the nearest weigh-in outside the log', () => {
+ expect(bodyweightAt(log, T0 + 15 * DAY)).toBe(80)
+ expect(bodyweightAt(log, T0 - 5 * DAY)).toBe(90)
+ })
+
+ it('gives up when the nearest weigh-in is too far away', () => {
+ expect(bodyweightAt(log, T0 + (10 + BW_MAX_GAP_DAYS + 1) * DAY)).toBeNull()
+ })
+
+ it('is null for an empty log', () => {
+ expect(bodyweightAt([], 0)).toBeNull()
+ expect(bodyweightAt(undefined, 0)).toBeNull()
+ })
+
+ it('reads a weigh-in with no timestamp from its date', () => {
+ expect(bodyweightAt([{ d: '2026-01-01', w: 70 }], new Date('2026-01-02').getTime())).toBe(70)
+ })
+})
+
+describe('effectiveLoad', () => {
+ it('is the logged weight for a normal lift', () => {
+ expect(effectiveLoad({}, 100, 80)).toBe(100)
+ })
+ it('adds the logged weight to body weight for a bodyweight exercise', () => {
+ expect(effectiveLoad({ bodyweight: true }, 0, 80)).toBe(80)
+ expect(effectiveLoad({ bodyweight: true }, 10, 80)).toBe(90)
+ })
+ it('takes the assistance off body weight', () => {
+ expect(effectiveLoad({ assisted: true }, 30, 80)).toBe(50)
+ expect(effectiveLoad({ assisted: true }, 200, 80)).toBe(0)
+ })
+})
+
+describe('relativeSeries', () => {
+ it('divides the best set\'s estimated 1RM by body weight', () => {
+ const S = state([workout(1000, [entry([done(100, 1), done(60, 5)])], 80)])
+ const [p] = relativeSeries(S, LIFT, { formula: 'epley' })
+ expect(p.y).toBeCloseTo(100 / 80)
+ expect(p.bw).toBe(80)
+ })
+
+ it('on the top-set basis uses the heaviest set', () => {
+ const S = state([workout(1000, [entry([done(100, 5), done(90, 8)])], 80)])
+ expect(relativeSeries(S, LIFT, { basis: 'top' })[0].y).toBeCloseTo(100 / 80)
+ })
+
+ it('falls back to the weigh-in log for a workout without its own', () => {
+ const T0 = 100 * DAY
+ const S = state([workout(T0 + 5 * DAY, [entry([done(85, 1)])])], [{ t: T0, w: 90 }, { t: T0 + 10 * DAY, w: 80 }])
+ expect(relativeSeries(S, LIFT)[0].bw).toBeCloseTo(85)
+ })
+
+ it('skips a workout with no usable body weight', () => {
+ expect(relativeSeries(state([workout(1000, [entry([done(100, 1)])])]), LIFT)).toEqual([])
+ })
+
+ it('bare bodyweight reps: the ratio follows reps, not body weight', () => {
+ const S = state([
+ workout(1000, [entry([done(0, 10)], { bodyweight: true })], 90),
+ workout(2000, [entry([done(0, 11)], { bodyweight: true })], 80),
+ ])
+ const [a, b] = relativeSeries(S, LIFT, { formula: 'epley' })
+ expect(a.y).toBeCloseTo(1 + 10 / 30)
+ expect(b.y).toBeCloseTo(1 + 11 / 30)
+ expect(b.y).toBeGreaterThan(a.y)
+ })
+
+ it('a weighted bodyweight set counts the body weight as load', () => {
+ const S = state([workout(1000, [entry([done(10, 1)], { bodyweight: true })], 80)])
+ expect(relativeSeries(S, LIFT)[0].y).toBeCloseTo(90 / 80)
+ })
+
+ it('assisted: less assistance gives a higher ratio', () => {
+ const S = state([
+ workout(1000, [entry([done(40, 1)], { assisted: true })], 80),
+ workout(2000, [entry([done(20, 1)], { assisted: true })], 80),
+ ])
+ const [a, b] = relativeSeries(S, LIFT)
+ expect(a.y).toBeCloseTo(40 / 80)
+ expect(b.y).toBeCloseTo(60 / 80)
+ })
+
+ it('ignores warm-ups and sets that were not done', () => {
+ const S = state([workout(1000, [entry([done(200, 1, { warmup: true }), { w: 150, r: 1, done: false }, done(100, 1)])], 100)])
+ expect(relativeSeries(S, LIFT)[0].y).toBeCloseTo(1)
+ })
+
+ it('reads a per-side set from its done sides', () => {
+ const S = state([workout(1000, [entry([{ sides: { L: done(40, 1), R: done(50, 1) } }])], 100)])
+ expect(relativeSeries(S, LIFT)[0].y).toBeCloseTo(0.5)
+ })
+})
+
+// Body weight is one number, so a dumbbell lift is measured by both bells together.
+describe('relativeSeries: dumbbells', () => {
+ const DB = '1175' // dumbbell forward leaning lunge: two bells
+ const ONE_ARM = '1048' // dumbbell lying one arm rear lateral raise: one bell
+ const bell = (id, w, dbLoad) => ({ id, sets: [done(w, 1)], ...(dbLoad ? { target: { dbLoad } } : {}) })
+ const y = (S, id) => relativeSeries(S, id, { formula: 'epley' })[0].y
+
+ it('counts "each" as both bells', () => {
+ expect(y(state([workout(1000, [bell(DB, 20, 'each')], 80)]), DB)).toBeCloseTo(40 / 80)
+ })
+
+ it('takes "total" as it stands', () => {
+ expect(y(state([workout(1000, [bell(DB, 40, 'total')], 80)]), DB)).toBeCloseTo(40 / 80)
+ })
+
+ it('gives the same ratio whichever meaning the exercise is set to now', () => {
+ const w = [workout(1000, [bell(DB, 20, 'each')], 80)]
+ for (const mode of ['each', 'total']) {
+ expect(y({ ...state(w), dbLoad: { [DB]: { mode, _ts: 1 } } }, DB)).toBeCloseTo(0.5)
+ }
+ })
+
+ it('leaves a set logged as entered at face value', () => {
+ expect(y(state([workout(1000, [bell(DB, 20)], 80)]), DB)).toBeCloseTo(20 / 80)
+ })
+
+ it('counts one bell for one-arm work', () => {
+ expect(y(state([workout(1000, [bell(ONE_ARM, 20, 'each')], 80)]), ONE_ARM)).toBeCloseTo(20 / 80)
+ })
+})
+
+describe('relativeSeries: weighted pull-ups and dips', () => {
+ const BELT = '2987' // weighted close grip chin-up: 'weighted' equipment, the belt plate is what is logged
+ const PULLUP = '0652' // pull-up: a body weight exercise by the catalogue
+
+ it('counts body weight under the plate on a belt chin-up, not the plate alone', () => {
+ const S = state([workout(1000, [{ id: BELT, sets: [done(20, 1)] }], 80)])
+ expect(relativeSeries(S, BELT)[0].y).toBeCloseTo(100 / 80)
+ })
+
+ it('reads a catalogue bodyweight exercise as one when its target carries no flag of its own', () => {
+ const S = state([workout(1000, [{ id: PULLUP, target: { mode: 'reps' }, sets: [done(10, 1)] }], 80)])
+ expect(relativeSeries(S, PULLUP)[0].y).toBeCloseTo(90 / 80)
+ })
+
+ it('lets the entry turn it off', () => {
+ const S = state([workout(1000, [{ id: PULLUP, target: { bodyweight: false }, sets: [done(60, 1)] }], 80)])
+ expect(relativeSeries(S, PULLUP)[0].y).toBeCloseTo(60 / 80)
+ })
+})
+
+describe('relativeSeries: assisted machines', () => {
+ const ASSISTED = '1431' // assisted standing chin-up
+ it('reads the catalogue flag: body weight minus the assistance, and less help ranks higher', () => {
+ const S = state([
+ workout(1000, [{ id: ASSISTED, sets: [done(30, 1)] }], 80),
+ workout(2000, [{ id: ASSISTED, sets: [done(10, 1)] }], 80),
+ ])
+ const [a, b] = relativeSeries(S, ASSISTED, { formula: 'epley' })
+ expect(a.y).toBeCloseTo(50 / 80)
+ expect(b.y).toBeCloseTo(70 / 80)
+ })
+ it('never extrapolates a 1RM: 9 reps with 11.4 kg of help at 90 kg stays under body weight', () => {
+ // The reported case. Epley on the 78.6 kg actually moved gave a 102 kg "1RM", 113 % of body weight.
+ const sets = [done(40.8, 12), done(11.4, 9), done(11.4, 9, { rir: 1 }), done(11.4, 8, { rir: 0.5 })]
+ const S = state([workout(1000, [{ id: ASSISTED, sets, target: { bodyweight: true } }], 90)])
+ for (const basis of ['e1rm', 'top']) {
+ const [p] = relativeSeries(S, ASSISTED, { basis })
+ expect(p.y).toBeCloseTo(78.6 / 90)
+ expect(p.y).toBeLessThan(1)
+ }
+ })
+ it('follows an assisted setting made on the routine, not only the catalogue', () => {
+ // LIFT is a plain barbell lift; the entry's own target says it was done with help.
+ const sets = [done(10, 9)]
+ const S = state([workout(1000, [{ id: LIFT, sets, target: { assisted: true } }], 80)])
+ const [p] = relativeSeries(S, LIFT, { basis: 'e1rm' })
+ expect(p.assisted).toBe(true)
+ expect(p.y).toBeCloseTo(70 / 80)
+ })
+ it('marks a normal lift as not assisted', () => {
+ expect(relativeSeries(state([workout(1000, [entry([done(100, 1)])], 80)]), LIFT)[0].assisted).toBe(false)
+ })
+ it('has no point when the assistance is at or above body weight', () => {
+ expect(relativeSeries(state([workout(1000, [{ id: ASSISTED, sets: [done(90, 1)] }], 80)]), ASSISTED)).toEqual([])
+ })
+})
diff --git a/frontend/src/lib/structuralBalance.js b/frontend/src/lib/structuralBalance.js
index 314a7b88c..924daf27a 100644
--- a/frontend/src/lib/structuralBalance.js
+++ b/frontend/src/lib/structuralBalance.js
@@ -49,7 +49,7 @@ const beltOnLifter = id => {
// body when the entry is flagged bodyweight — would score more help as a stronger lift. A 0
// there is a row with no help entered, not a set done without any (history.js), and help at or
// above body mass moved nothing: both are left unscored.
-const onLifter = entry => {
+export const onLifter = entry => {
const bodyweight = entry.target?.bodyweight ?? entry.bodyweight
return bodyweight == null ? isBw({ id: entry.id }) || beltOnLifter(entry.id) : !!bodyweight
}
diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.js
index a7e7e8be3..9a58361bd 100644
--- a/frontend/src/locales/ar.js
+++ b/frontend/src/locales/ar.js
@@ -2584,4 +2584,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "التنشيف غالبًا 0.5 إلى 1 % أسبوعيًا، والتضخيم النظيف 0.25 إلى 0.5 %.",
"Remove range": "إزالة النطاق",
'Admin': 'المشرف',
+ 'Heaviest set as a share of body weight, per workout': 'أثقل مجموعة كنسبة من وزن الجسم، لكل تمرين',
+ 'Estimated 1RM as a share of body weight, per workout': 'الحد الأقصى المقدّر لتكرار واحد (1RM) كنسبة من وزن الجسم، لكل تمرين',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'وزن الجسم خلال هذه الفترة: {0} → {1}. تحتسب تمارين وزن الجسم والتمارين المساعدة وزن جسمك كجزء من الحمل.',
}
diff --git a/frontend/src/locales/bn.js b/frontend/src/locales/bn.js
index 033c13bc9..dfe79893a 100644
--- a/frontend/src/locales/bn.js
+++ b/frontend/src/locales/bn.js
@@ -2608,4 +2608,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "কাটিং সাধারণত সপ্তাহে ০.৫ থেকে ১ %, লিন বাল্ক ০.২৫ থেকে ০.৫ %।",
"Remove range": "সীমা সরান",
'Admin': 'অ্যাডমিন',
+ 'Heaviest set as a share of body weight, per workout': 'প্রতি ওয়ার্কআউটে শরীরের ওজনের অনুপাতে সবচেয়ে ভারী সেট',
+ 'Estimated 1RM as a share of body weight, per workout': 'প্রতি ওয়ার্কআউটে শরীরের ওজনের অনুপাতে আনুমানিক 1RM',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'এই সময়ে শরীরের ওজন: {0} → {1}। বডিওয়েট ও অ্যাসিস্টেড ব্যায়ামে আপনার শরীরের ওজন লোডের অংশ হিসেবে ধরা হয়।',
}
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index d22bec1cb..59924d534 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -2549,4 +2549,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "Eine Diät liegt oft bei 0,5 bis 1 % pro Woche, ein sauberer Aufbau bei 0,25 bis 0,5 %.",
"Remove range": "Bereich entfernen",
'Admin': 'Admin',
+ 'Heaviest set as a share of body weight, per workout': 'Schwerster Satz im Verhältnis zum Körpergewicht, pro Training',
+ 'Estimated 1RM as a share of body weight, per workout': 'Geschätztes 1RM im Verhältnis zum Körpergewicht, pro Training',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'Körpergewicht in diesem Zeitraum: {0} → {1}. Bei Körpergewichts- und assistierten Übungen zählt dein Körpergewicht als Teil der Last.',
}
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index e5ed22d4a..5d6aea79d 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -2529,4 +2529,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "Una definición suele ir de 0,5 a 1 % por semana, un volumen limpio de 0,25 a 0,5 %.",
"Remove range": "Quitar rango",
'Admin': 'Admin',
+ 'Heaviest set as a share of body weight, per workout': 'Serie más pesada como proporción del peso corporal, por entrenamiento',
+ 'Estimated 1RM as a share of body weight, per workout': '1RM estimado como proporción del peso corporal, por entrenamiento',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'Peso corporal en este periodo: {0} → {1}. En los ejercicios con peso corporal y asistidos, tu peso corporal cuenta como parte de la carga.',
}
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index 17e33ccb3..8637f4ed2 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -2529,4 +2529,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "Une sèche, c’est souvent 0,5 à 1 % par semaine, une prise de masse propre 0,25 à 0,5 %.",
"Remove range": "Retirer la fourchette",
'Admin': 'Admin',
+ 'Heaviest set as a share of body weight, per workout': 'Série la plus lourde en proportion du poids de corps, par séance',
+ 'Estimated 1RM as a share of body weight, per workout': '1RM estimé en proportion du poids de corps, par séance',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'Poids de corps sur cette période : {0} → {1}. Pour les exercices au poids de corps et assistés, ton poids de corps compte dans la charge.',
}
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index da47d026a..00417a16d 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -2529,4 +2529,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "कटिंग अक्सर हर हफ़्ते 0.5 से 1 % होती है, लीन बल्क 0.25 से 0.5 %।",
"Remove range": "सीमा हटाएँ",
'Admin': 'एडमिन',
+ 'Heaviest set as a share of body weight, per workout': 'प्रति वर्कआउट शरीर के वज़न के अनुपात में सबसे भारी सेट',
+ 'Estimated 1RM as a share of body weight, per workout': 'प्रति वर्कआउट शरीर के वज़न के अनुपात में अनुमानित 1RM',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'इस अवधि में शरीर का वज़न: {0} → {1}। बॉडीवेट और असिस्टेड व्यायामों में आपके शरीर का वज़न लोड का हिस्सा माना जाता है।',
}
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index ff3891c01..ecdcc8598 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -2532,4 +2532,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "Szálkásításnál gyakran heti 0,5–1 %, tiszta tömegnövelésnél 0,25–0,5 %.",
"Remove range": "Tartomány törlése",
'Admin': 'Admin',
+ 'Heaviest set as a share of body weight, per workout': 'A legnehezebb sorozat a testsúly arányában, edzésenként',
+ 'Estimated 1RM as a share of body weight, per workout': 'Becsült 1RM a testsúly arányában, edzésenként',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'Testsúly ebben az időszakban: {0} → {1}. A testsúlyos és segített gyakorlatoknál a testsúlyod is a terhelés részének számít.',
}
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index d9586f6a9..066a244fd 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -2529,4 +2529,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "Una definizione è spesso 0,5-1 % a settimana, una massa pulita 0,25-0,5 %.",
"Remove range": "Rimuovi intervallo",
'Admin': 'Admin',
+ 'Heaviest set as a share of body weight, per workout': 'Serie più pesante in proporzione al peso corporeo, per allenamento',
+ 'Estimated 1RM as a share of body weight, per workout': '1RM stimato in proporzione al peso corporeo, per allenamento',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'Peso corporeo in questo periodo: {0} → {1}. Negli esercizi a corpo libero e assistiti il tuo peso corporeo conta come parte del carico.',
}
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index 3ed61e60b..01cbf0b3a 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -2529,4 +2529,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "감량기는 보통 주당 0.5~1 %, 린 벌크는 0.25~0.5 % 정도예요.",
"Remove range": "범위 삭제",
'Admin': '관리자',
+ 'Heaviest set as a share of body weight, per workout': '운동별 체중 대비 가장 무거운 세트',
+ 'Estimated 1RM as a share of body weight, per workout': '운동별 체중 대비 추정 1RM',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': '이 기간의 체중: {0} → {1}. 맨몸 운동과 보조 운동에서는 체중이 부하의 일부로 계산됩니다.',
}
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index 453e12717..c61924ed8 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -2529,4 +2529,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "Redukcja to często 0,5 do 1 % tygodniowo, czysta masa 0,25 do 0,5 %.",
"Remove range": "Usuń zakres",
'Admin': 'Admin',
+ 'Heaviest set as a share of body weight, per workout': 'Najcięższa seria jako odsetek masy ciała, na trening',
+ 'Estimated 1RM as a share of body weight, per workout': 'Szacowane 1RM jako odsetek masy ciała, na trening',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'Masa ciała w tym okresie: {0} → {1}. W ćwiczeniach z masą ciała i wspomaganych Twoja masa ciała liczy się jako część obciążenia.',
}
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index 8bf6b7fc1..0e54c5a2e 100644
--- a/frontend/src/locales/pt-BR.js
+++ b/frontend/src/locales/pt-BR.js
@@ -1365,6 +1365,7 @@ export const PT_BR_OVERRIDES = {
'Coach wants you back on the bar.': 'O coach quer você de volta na barra.',
'Gentle, for headphones or a quiet room.': 'Suave, para fones de ouvido ou um lugar silencioso.',
'Fewer than two workouts in this period. Pick a longer one.': 'Menos de dois treinos neste período. Escolha um mais longo.',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'Peso corporal neste período: {0} → {1}. Nos exercícios com peso corporal e assistidos, o seu peso corporal conta como parte da carga.',
'Releases are checked on GitHub. The download is verified against its checksum before the installer opens.': 'As versões são verificadas no GitHub. O download é conferido pela soma de verificação antes de abrir o instalador.',
// --- Coach: AI data sharing ---
'AI data sharing': 'Compartilhamento de dados com IA',
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index 91e16dac8..2c3899679 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -2529,4 +2529,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "Uma fase de definição anda muitas vezes nos 0,5 a 1 % por semana, um bulk limpo nos 0,25 a 0,5 %.",
"Remove range": "Remover intervalo",
'Admin': 'Admin',
+ 'Heaviest set as a share of body weight, per workout': 'Série mais pesada como proporção do peso corporal, por treino',
+ 'Estimated 1RM as a share of body weight, per workout': '1RM estimado como proporção do peso corporal, por treino',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'Peso corporal neste período: {0} → {1}. Nos exercícios com peso corporal e assistidos, o teu peso corporal conta como parte da carga.',
}
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index 72ee9437d..fb574c626 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -2533,4 +2533,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "Сушка обычно идёт по 0,5–1 % в неделю, чистый набор по 0,25–0,5 %.",
"Remove range": "Убрать диапазон",
'Admin': 'Админ',
+ 'Heaviest set as a share of body weight, per workout': 'Самый тяжёлый подход как доля от веса тела, по тренировкам',
+ 'Estimated 1RM as a share of body weight, per workout': 'Расчётный 1ПМ как доля от веса тела, по тренировкам',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'Вес тела за этот период: {0} → {1}. В упражнениях с собственным весом и в гравитронных вес вашего тела входит в нагрузку.',
}
diff --git a/frontend/src/locales/sv.js b/frontend/src/locales/sv.js
index bc6b590d3..7a75ec369 100644
--- a/frontend/src/locales/sv.js
+++ b/frontend/src/locales/sv.js
@@ -2576,4 +2576,7 @@ export default {
'A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.': 'En deff är ofta 0,5 till 1 % i veckan, en lean bulk 0,25 till 0,5 %.',
'Remove range': 'Ta bort intervall',
'Admin': 'Admin',
+ 'Heaviest set as a share of body weight, per workout': 'Tyngsta setet som andel av kroppsvikten, per pass',
+ 'Estimated 1RM as a share of body weight, per workout': 'Uppskattat 1RM som andel av kroppsvikten, per pass',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'Kroppsvikt under perioden: {0} → {1}. I kroppsviktsövningar och assisterade övningar räknas din kroppsvikt som en del av belastningen.',
}
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index fe447a9f0..8e7e01883 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -2540,4 +2540,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "ช่วงลดไขมันมักอยู่ที่ 0.5 ถึง 1 % ต่อสัปดาห์ ช่วงเพิ่มกล้ามแบบลีนอยู่ที่ 0.25 ถึง 0.5 %",
"Remove range": "ลบช่วง",
'Admin': 'ผู้ดูแล',
+ 'Heaviest set as a share of body weight, per workout': 'เซ็ตที่หนักที่สุดเทียบกับน้ำหนักตัว ต่อการเทรนแต่ละครั้ง',
+ 'Estimated 1RM as a share of body weight, per workout': '1RM โดยประมาณเทียบกับน้ำหนักตัว ต่อการเทรนแต่ละครั้ง',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'น้ำหนักตัวในช่วงนี้: {0} → {1} ท่าที่ใช้น้ำหนักตัวและท่าที่มีตัวช่วยจะนับน้ำหนักตัวของคุณเป็นส่วนหนึ่งของน้ำหนักที่ยก',
}
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index 0bc0b66f2..7a7183a0f 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -2529,4 +2529,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "Yağ yakımı genelde haftada %0,5 ile %1, temiz bulk %0,25 ile %0,5 arasıdır.",
"Remove range": "Aralığı kaldır",
'Admin': 'Yönetici',
+ 'Heaviest set as a share of body weight, per workout': 'Antrenman başına vücut ağırlığına oranla en ağır set',
+ 'Estimated 1RM as a share of body weight, per workout': 'Antrenman başına vücut ağırlığına oranla tahmini 1RM',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'Bu dönemdeki vücut ağırlığı: {0} → {1}. Vücut ağırlığı ve destekli egzersizlerde vücut ağırlığın yükün bir parçası sayılır.',
}
diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.js
index a974521e5..66b789140 100644
--- a/frontend/src/locales/uk.js
+++ b/frontend/src/locales/uk.js
@@ -2526,4 +2526,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "Сушка часто йде по 0,5–1 % на тиждень, чистий набір по 0,25–0,5 %.",
"Remove range": "Прибрати діапазон",
'Admin': 'Адмін',
+ 'Heaviest set as a share of body weight, per workout': 'Найважчий підхід як частка ваги тіла, за тренуваннями',
+ 'Estimated 1RM as a share of body weight, per workout': 'Розрахунковий 1ПМ як частка ваги тіла, за тренуваннями',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': 'Вага тіла за цей період: {0} → {1}. У вправах із власною вагою та з допомогою вага вашого тіла входить у навантаження.',
}
diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.js
index 03f45c498..2a79db34e 100644
--- a/frontend/src/locales/zh-TW.js
+++ b/frontend/src/locales/zh-TW.js
@@ -2522,4 +2522,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "減脂期通常每週 0.5 到 1 %,乾淨增肌每週 0.25 到 0.5 %。",
"Remove range": "移除範圍",
'Admin': '管理員',
+ 'Heaviest set as a share of body weight, per workout': '每次訓練中最重一組佔體重的比例',
+ 'Estimated 1RM as a share of body weight, per workout': '每次訓練的預估 1RM 佔體重的比例',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': '此期間的體重:{0} → {1}。徒手與輔助動作會把你的體重計入負重。',
}
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index a8c6e2cf5..4b4056a8f 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -2529,4 +2529,7 @@ export default {
"A cut is often 0.5 to 1 % a week, a lean bulk 0.25 to 0.5 %.": "减脂期通常每周 0.5 到 1 %,干净增肌每周 0.25 到 0.5 %。",
"Remove range": "移除范围",
'Admin': '管理员',
+ 'Heaviest set as a share of body weight, per workout': '每次训练中最重一组占体重的比例',
+ 'Estimated 1RM as a share of body weight, per workout': '每次训练的预估 1RM 占体重的比例',
+ 'Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.': '此期间的体重:{0} → {1}。自重和辅助动作会把你的体重计入负重。',
}
diff --git a/frontend/src/sheets.history.test.jsx b/frontend/src/sheets.history.test.jsx
index 5967ae254..4921ec864 100644
--- a/frontend/src/sheets.history.test.jsx
+++ b/frontend/src/sheets.history.test.jsx
@@ -72,6 +72,62 @@ describe('exercise history sheet', () => {
expect(host.textContent).toContain('70 kg')
})
+ it('offers a Bodyweight curve only with two sessions that have a body weight, and Best becomes a percentage', () => {
+ const rel = (i, w, bw) => ({ ...session(i, [{ w, r: 5, done: true }]), bw })
+ useStore.setState(s => ({ S: { ...s.S, bodyweight: [], workouts: [session(0, [{ w: 60, r: 5, done: true }]), session(2, [{ w: 70, r: 5, done: true }])] } }))
+ exerciseHistorySheet(EX)
+ const none = renderTop()
+ expect([...none.querySelectorAll('.seg button')].map(b => b.textContent)).not.toContain('Bodyweight')
+
+ useUI.setState({ sheets: [] })
+ useStore.setState(s => ({ S: { ...s.S, workouts: [rel(0, 60, 80), rel(2, 80, 80)] } }))
+ exerciseHistorySheet(EX)
+ const host = renderTop()
+ const btn = [...host.querySelectorAll('.seg button')].find(b => b.textContent === 'Bodyweight')
+ expect(btn).toBeTruthy()
+ act(() => { btn.click() })
+ expect(host.textContent).toMatch(/Best:\s*\d+(\.\d+)? % BW/)
+ expect(host.textContent).toContain('Estimated 1RM as a share of body weight, per workout')
+ })
+
+ it('gives a bare bodyweight exercise a Max reps / Bodyweight toggle, counting body weight as the load', () => {
+ const bare = (i, r) => ({ ...session(i, [{ w: 0, r, done: true }]), bw: 80,
+ entries: [{ id: EX, target: { mode: 'reps', bodyweight: true }, sets: [{ w: 0, r, done: true }] }] })
+ useStore.setState(s => ({ S: { ...s.S, bodyweight: [], workouts: [bare(0, 5), bare(2, 10)] } }))
+ exerciseHistorySheet(EX)
+ const host = renderTop()
+ expect([...host.querySelectorAll('.seg button')].map(b => b.textContent)).toEqual(['Max reps', 'Bodyweight'])
+ act(() => { [...host.querySelectorAll('.seg button')].find(b => b.textContent === 'Bodyweight').click() })
+ // 80 kg moved for 10 reps estimates above body weight, so the best is over 100 % BW.
+ const best = Number(host.textContent.match(/Best:\s*([\d.]+) % BW/)?.[1])
+ expect(best).toBeGreaterThan(100)
+ })
+
+ it('on an assisted machine, less help reads as a higher percentage of body weight', () => {
+ const AS = '1431'
+ const at = (i, help) => ({ ...session(i, []), bw: 80, entries: [{ id: AS, target: { mode: 'reps' }, sets: [{ w: help, r: 5, done: true }] }] })
+ useStore.setState(s => ({ S: { ...s.S, bodyweight: [], workouts: [at(0, 30), at(2, 10)] } }))
+ exerciseHistorySheet(AS)
+ const host = renderTop()
+ act(() => { [...host.querySelectorAll('.seg button')].find(b => b.textContent === 'Bodyweight').click() })
+ const best = Number(host.textContent.match(/Best:\s*([\d.]+) % BW/)?.[1])
+ // The heaviest set, not an extrapolated 1RM: 70 of 80 kg is 87.5 %, so it can never pass 100.
+ expect(best).toBeCloseTo(87.5, 1)
+ expect(host.textContent).toContain('Heaviest set as a share of body weight, per workout')
+ })
+
+ it('keeps a Bodyweight curve for high-rep work the 1RM estimate refuses, following the heaviest set', () => {
+ // 20 reps is above the estimate's cap, so there is no Est. 1RM; leg press and calf raises live here.
+ const high = (i, w) => ({ ...session(i, [{ w, r: 20, done: true }]), bw: 80 })
+ useStore.setState(s => ({ S: { ...s.S, bodyweight: [], workouts: [high(0, 100), high(2, 120)] } }))
+ exerciseHistorySheet(EX)
+ const host = renderTop()
+ expect([...host.querySelectorAll('.seg button')].map(b => b.textContent)).toEqual(['Top set', 'Bodyweight'])
+ act(() => { [...host.querySelectorAll('.seg button')].find(b => b.textContent === 'Bodyweight').click() })
+ expect(Number(host.textContent.match(/Best:\s*([\d.]+) % BW/)?.[1])).toBeCloseTo(150, 1)
+ expect(host.textContent).toContain('Heaviest set as a share of body weight, per workout')
+ })
+
it('is reachable from the exercise detail sheet once there is history', () => {
exerciseDetailSheet(EXIDX[EX])
const before = renderTop()
diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx
index 0a3e9b0d5..8b46c71eb 100644
--- a/frontend/src/sheets.jsx
+++ b/frontend/src/sheets.jsx
@@ -40,6 +40,7 @@ import { printOptions } from './lib/print-doc.js'
import { printWorkout } from './lib/report-print.js'
import { estimate1RM, best1RM, is1RMRecord, REP_CAP, formulaOf, FORMULA_NAMES } from './lib/onerm.js'
import { exerciseHistory } from './lib/exercise-history.js'
+import { relativeSeries } from './lib/relative-strength.js'
import { isBellEx, dbLoadOf, dbLoadFor, withDbLoad, entryDbLoad, currentDbLoad, isOneArm, dumbbellsOf, ownsDumbbells, withDumbbells, presetWeights, cleanWeights } from './lib/dumbbells.js'
import { policyFor, defaultIncrement, POLICIES_FOR, POLICY_NAME, POLICY_DESC, MAX_BW_SETS, MAX_TRIPLE_SETS } from './lib/progression.js'
import { normalizeRepRange } from './lib/rep-range.js'
@@ -1127,9 +1128,34 @@ function ExerciseHistory({ exId }) {
const ex = exOr(exId)
const h = useMemo(() => exerciseHistory(st, exId), [st.workouts, exId, st.volumeWarmups])
const [curve, setCurve] = useState('top')
- const onE1 = curve === 'e1rm' && h.e1rmPoints.length > 0
+ // Against body weight, as in Stats: the estimated 1RM (body weight included for bodyweight and
+ // assisted work) as a % of the body weight then. Only for rep work, and only once two sessions
+ // have a body weight to compare with.
+ const formula = formulaOf(st)
+ // The 1RM estimate refuses sets above ~12 reps (lib/onerm.js REP_CAP), so a calf raise or a leg
+ // press done for 15-20 has none; its curve then follows the heaviest set instead (as Stats does),
+ // when that one varies. An assistance machine has no 1RM either, and is always the heaviest set.
+ const { pts: rel, top: relTop } = useMemo(() => {
+ if (h.metric !== 'weight' && h.metric !== 'reps') return { pts: [], top: false }
+ const toPct = p => ({ t: p.t, d: p.d, y: p.y * 100, assisted: p.assisted })
+ const est = relativeSeries(st, exId, { basis: 'e1rm', formula })
+ if (est.length >= 2) return { pts: est.map(toPct), top: est.some(p => p.assisted) }
+ const top = relativeSeries(st, exId, { basis: 'top', formula })
+ const varies = top.length >= 2 && top.some(p => Math.abs(p.y - top[0].y) > 1e-9)
+ return varies ? { pts: top.map(toPct), top: true } : { pts: [], top: false }
+ }, [st.workouts, st.bodyweight, st.dbLoad, exId, h.metric, formula])
+ const canRel = rel.length >= 2
+ const onRel = curve === 'bodyweight' && canRel
+ const onE1 = !onRel && curve === 'e1rm' && h.e1rmPoints.length > 0
const unit = h.metric === 'weight' ? st.unit : h.metric === 'reps' ? t('reps') : h.metric === 'sec' ? 's' : t('min')
const e1Best = useMemo(() => Math.max(0, ...h.e1rmPoints.map(p => p.y)), [h])
+ const relBest = useMemo(() => Math.max(0, ...rel.map(p => p.y)), [rel])
+ const curveOpts = []
+ if (h.e1rmPoints.length > 0 && h.metric === 'weight') curveOpts.push({ value: 'top', label: t('Top set') }, { value: 'e1rm', label: t('Est. 1RM') })
+ if (canRel) {
+ if (!curveOpts.length) curveOpts.push({ value: 'top', label: h.metric === 'reps' ? t('Max reps') : t('Top set') })
+ curveOpts.push({ value: 'bodyweight', label: t('Bodyweight') })
+ }
if (!h.total) return <>
<h3 className={exerciseNameClass(ex)}>{exerciseNameFor(ex)}</h3>
<div className="empty"><div className="ico"><Icon name="history" /></div>{t('No sessions logged yet')}</div>
@@ -1142,15 +1168,15 @@ function ExerciseHistory({ exId }) {
<h3 className={exerciseNameClass(ex)} style={{ marginBottom: 2 }}>{exerciseNameFor(ex)}</h3>
<div className="muted small" style={{ marginBottom: 10 }}>{t('Exercise history')} · {tn('{0} session', '{0} sessions', h.total)}</div>
{/* Only reps work with a load produces an estimate, so the toggle is absent for the rest. */}
- {h.e1rmPoints.length > 0 && h.metric === 'weight' && <Segmented className="seg-range" value={curve} onChange={setCurve}
- options={[{ value: 'top', label: t('Top set') }, { value: 'e1rm', label: t('Est. 1RM') }]} />}
+ {curveOpts.length > 1 && <Segmented className="seg-range" value={onRel ? 'bodyweight' : onE1 ? 'e1rm' : 'top'} onChange={setCurve} options={curveOpts} />}
<div className="chart" style={{ marginTop: 8 }}>
- <LineChart points={onE1 ? h.e1rmPoints : h.points} h={140} unit={onE1 ? st.unit : unit} color="var(--blue)" />
+ <LineChart points={onRel ? rel : onE1 ? h.e1rmPoints : h.points} h={140} unit={onRel ? '% BW' : onE1 ? st.unit : unit} color="var(--blue)" />
</div>
<div className="small row" style={{ margin: '6px 0 4px', gap: 5 }}>
<Icon name="trophy" style={{ fontSize: 14, color: 'var(--yellow)' }} />
- {t('Best:')} <b className="accent">{fmtNum(onE1 ? e1Best : h.best)} {onE1 ? st.unit : unit}</b>
+ {t('Best:')} <b className="accent">{onRel ? fmtNum(relBest) + ' % BW' : fmtNum(onE1 ? e1Best : h.best) + ' ' + (onE1 ? st.unit : unit)}</b>
</div>
+ {onRel && <div className="small dim">{relTop ? t('Heaviest set as a share of body weight, per workout') : t('Estimated 1RM as a share of body weight, per workout')}</div>}
<h4 className="sec">{h.sessions.length < h.total ? t('Last {0} sessions', h.sessions.length) : t('Sessions')}</h4>
<div className="list">
{h.sessions.map(s => <div key={s.id} className="item" style={{ alignItems: 'flex-start' }}>
diff --git a/frontend/src/views/Stats.bodyweight.test.jsx b/frontend/src/views/Stats.bodyweight.test.jsx
new file mode 100644
index 000000000..6b75e720d
--- /dev/null
+++ b/frontend/src/views/Stats.bodyweight.test.jsx
@@ -0,0 +1,122 @@
+// @vitest-environment happy-dom
+// The Bodyweight view of Exercise progress: a lift measured against body weight at the time.
+import React, { act } from 'react'
+import { createRoot } from 'react-dom/client'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import Stats from './Stats.jsx'
+
+const mocks = vi.hoisted(() => ({ charts: [], S: null }))
+vi.mock('../store/useStore.js', () => ({ useStore: selector => selector({ S: mocks.S }) }))
+vi.mock('react-router-dom', () => ({ useNavigate: () => () => {} }))
+vi.mock('../sheets.jsx', () => ({
+ bwSheet: () => {}, goalSheet: () => {}, calendarSheet: () => {}, workoutDetailSheet: () => {}, exerciseHistorySheet: () => {},
+ WorkoutRow: () => null, bwDeltaColor: () => 'inherit',
+}))
+vi.mock('../components/LineChart.jsx', () => ({ default: props => { mocks.charts.push(props); return null } }))
+vi.mock('../components/Heatmap.jsx', () => ({ default: () => null }))
+vi.mock('../components/BodyMap.jsx', () => ({ default: () => null, BodyMapLegend: () => null }))
+
+globalThis.IS_REACT_ACT_ENVIRONMENT = true
+const BENCH = '0025'
+const DAY = 86400000
+// A bench session `ago` days back: two sets at weight w, logged at body weight bw (when given).
+const session = (ago, w, bw) => {
+ const start = Date.now() - ago * DAY
+ return {
+ id: 'w' + ago, d: new Date(start).toISOString().slice(0, 10), start, end: start + 3600000, name: 'Push',
+ ...(bw ? { bw } : {}),
+ entries: [{ id: BENCH, target: { id: BENCH, sets: 2, reps: 5 }, sets: [{ w, r: 5, done: true }, { w, r: 4, done: true }] }],
+ }
+}
+let root, host
+afterEach(() => { act(() => root.unmount()); host.remove(); mocks.charts = [] })
+
+function mount(workouts) {
+ mocks.S = { body: 'male', effort: 'none', unit: 'kg', targetW: null, bodyweight: [], routines: [], exWeights: {}, workouts }
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ root = createRoot(host)
+ act(() => root.render(<Stats />))
+}
+const exCard = () => [...host.querySelectorAll('.card')].find(c => c.querySelector('h2')?.textContent === 'Exercise progress')
+const press = (scope, label) => act(() => [...scope.querySelectorAll('.seg button')].find(b => b.textContent === label).click())
+const labels = scope => [...scope.querySelectorAll('.seg button')].map(b => b.textContent)
+const lastChart = () => mocks.charts.at(-1)
+
+describe('Stats: Bodyweight view of exercise progress', () => {
+ it('is not offered without a body weight to compare with, or with a single workout', () => {
+ mount([session(20, 80), session(10, 85)])
+ expect(labels(exCard())).not.toContain('Bodyweight')
+ act(() => root.unmount()); host.remove()
+ mount([session(10, 80, 80)])
+ expect(labels(exCard())).not.toContain('Bodyweight')
+ })
+
+ it('draws the lift as a percentage of the body weight it was logged at', () => {
+ mount([session(20, 80, 80), session(10, 100, 80)])
+ const card = exCard()
+ expect(labels(card)).toContain('Bodyweight')
+ press(card, 'Bodyweight')
+ const chart = lastChart()
+ expect(chart.unit).toBe('% BW')
+ const ys = chart.points.map(p => p.y)
+ expect(ys).toHaveLength(2)
+ expect(ys[1]).toBeGreaterThan(ys[0])
+ // Gaining the same weight as the lift leaves the ratio where it was.
+ expect(card.textContent).toContain('Body weight over this period: 80 kg → 80 kg.')
+ })
+
+ it('offers the basis toggle, and the top set reads the heaviest set over body weight', () => {
+ mount([session(20, 80, 80), session(10, 100, 80)])
+ const card = exCard()
+ press(card, 'Bodyweight')
+ const toggle = [...card.querySelectorAll('.seg')].find(s => labels(s).join() === 'Est. 1RM,Top set')
+ expect(toggle).toBeTruthy()
+ act(() => [...toggle.querySelectorAll('button')].find(b => b.textContent === 'Top set').click())
+ expect(lastChart().points.map(p => p.y)).toEqual([100, 125])
+ expect(card.textContent).toContain('Heaviest set as a share of body weight, per workout')
+ })
+
+ it('names the estimated 1RM, not a weight lifted, in the point note', () => {
+ mount([session(20, 80, 80), session(10, 100, 80)])
+ press(exCard(), 'Bodyweight')
+ expect(lastChart().points.every(p => p.note.startsWith('Est. 1RM '))).toBe(true)
+ })
+
+ it('offers no Est. 1RM basis for an exercise assisted by its routine setting, and says heaviest set', () => {
+ const assisted = (ago, help) => {
+ const s = session(ago, help, 80)
+ s.entries[0].target = { ...s.entries[0].target, assisted: true }
+ return s
+ }
+ mount([assisted(20, 30), assisted(10, 10)])
+ const card = exCard()
+ press(card, 'Bodyweight')
+ expect([...card.querySelectorAll('.seg')].some(s => labels(s).join() === 'Est. 1RM,Top set')).toBe(false)
+ expect(card.textContent).toContain('Heaviest set as a share of body weight, per workout')
+ expect(lastChart().points.map(p => p.y)).toEqual([62.5, 87.5])
+ })
+
+ it('still offers Bodyweight for sets above the 1RM estimate cap, on the heaviest set', () => {
+ const high = (ago, w) => {
+ const s = session(ago, w, 80)
+ s.entries[0].sets = [{ w, r: 20, done: true }]
+ return s
+ }
+ mount([high(20, 100), high(10, 120)])
+ const card = exCard()
+ expect(labels(card)).toContain('Bodyweight')
+ press(card, 'Bodyweight')
+ expect(lastChart().points.map(p => p.y)).toEqual([125, 150])
+ expect(card.textContent).toContain('Heaviest set as a share of body weight, per workout')
+ })
+
+ it('follows the date range and says so when it holds fewer than two workouts', () => {
+ mount([session(200, 70, 80), session(20, 80, 80), session(5, 90, 80)])
+ const card = exCard()
+ press(card, 'Bodyweight')
+ expect(lastChart().points).toHaveLength(3)
+ press(card, '1M')
+ expect(lastChart().points).toHaveLength(2)
+ })
+})
diff --git a/frontend/src/views/Stats.jsx b/frontend/src/views/Stats.jsx
index dd91e3912..f41d28659 100644
--- a/frontend/src/views/Stats.jsx
+++ b/frontend/src/views/Stats.jsx
@@ -23,6 +23,7 @@ import { currentDbLoad, workoutAs } from '../lib/dumbbells.js'
import { maxRepsSeries } from '../lib/pyramid.js'
import { weighInAt } from '../lib/bodyweight.js'
import { perSetSessions, perSetLines, dropOffSet } from '../lib/per-set.js'
+import { relativeSeries } from '../lib/relative-strength.js'
import {
hasEffort, hasEstimableEffort, displayScale, scaleName, toScale, avgRir, effortSummary, effortWeeks,
effortHistogram, isHardSet, HARD_RIR
@@ -483,6 +484,8 @@ export default function Stats() {
}, [])
const [exId, setExId] = useState(null)
const [exMetric, setExMetric] = useState('top')
+ // What the Body weight view measures the lift by: 'e1rm' (default) or the heaviest set.
+ const [relBasis, setRelBasis] = useState('e1rm')
// Exercise progress over a date range (issue #511), All by default. Only the chart follows it:
// "Best:" and the recent sessions under it stay all-time.
const [exRange, setExRange] = useState(0)
@@ -679,6 +682,23 @@ export default function Stats() {
const series = perSet.series.map(s => ({ ...s, points: s.points.filter(p => p.t >= exFrom) })).filter(s => s.points.length)
return { anchors: perSet.anchors.filter(p => p.t >= exFrom), series, ns: series.map(s => s.n) }
}, [perSet, exFrom])
+ // Progress against body weight: the lift's effective load (body weight included for bodyweight
+ // and assisted work) as a share of the body weight at the time, so it only rises when you got
+ // stronger for your size. Both bases are memoised on the same inputs as e1Pts, for the same reason.
+ // On a top-set basis a bare bodyweight exercise is a flat 100%, so that basis is only offered
+ // when it actually varies.
+ const relE1 = useMemo(() => (curEx && curMode === 'reps' ? relativeSeries(S, curEx, { basis: 'e1rm' }) : []), [S, curEx, curMode])
+ const relTop = useMemo(() => (curEx && curMode === 'reps' ? relativeSeries(S, curEx, { basis: 'top' }) : []), [S, curEx, curMode])
+ const canRelE1 = relE1.length >= 2 && !relE1.some(p => p.assisted)
+ const canRelTop = relTop.length >= 2 && relTop.some(p => Math.abs(p.y - relTop[0].y) > 1e-9)
+ const relUsed = relBasis === 'top' ? (canRelTop ? 'top' : 'e1rm') : (canRelE1 ? 'e1rm' : 'top')
+ const relPts = relUsed === 'top' ? relTop : relE1
+ const relChartPts = useMemo(() => relPts.filter(p => p.t >= exFrom).map(p => ({
+ t: p.t, y: p.y * 100, d: p.d,
+ note: (relUsed === 'e1rm' ? t('Est. 1RM') + ' ' : '') + fmtNum(p.load) + ' ' + S.unit + ' @ ' + fmtNum(p.bw) + ' ' + S.unit,
+ })), [relPts, relUsed, exFrom, S.unit])
+ const showRel = canRelE1 || canRelTop
+ const onRel = showRel && exMetric === 'bodyweight'
const onSets = !!perSet && exMetric === 'sets'
const onE1 = showE1 && exMetric === 'e1rm'
const onEff = showEff && exMetric === 'effort'
@@ -689,7 +709,7 @@ export default function Stats() {
m: exRir[i] == null ? null : 1 - Math.min(4, Math.max(0, exRir[i])) / 4,
note: exRir[i] == null ? undefined : hd + ' ' + fmtNum(toScale(kind, exRir[i]))
})).filter(inExRange)
- const chartPts = onSets ? perSetChart.anchors : onMax ? maxChartPts : onEff ? effPts : onE1 ? e1ChartPts : topPts
+ const chartPts = onSets ? perSetChart.anchors : onRel ? relChartPts : onMax ? maxChartPts : onEff ? effPts : onE1 ? e1ChartPts : topPts
// A line needs two workouts. A range that holds fewer says so, instead of a lone dot or an empty box.
const rangeTooShort = exRange !== 0 && chartPts.length < 2
const exOpts = [{ value: 'top', label: t('Top set') }]
@@ -697,6 +717,7 @@ export default function Stats() {
if (showE1) exOpts.push({ value: 'e1rm', label: t('Est. 1RM') })
if (showEff) exOpts.push({ value: 'effort', label: t('Effort') })
if (showMax) exOpts.push({ value: 'max', label: t('Max reps') })
+ if (showRel) exOpts.push({ value: 'bodyweight', label: t('Bodyweight') })
return <>
<div className="hdr"><div><h1>{t('Stats')}</h1><div className="sub">{t('Progress & history')}</div></div>
@@ -779,13 +800,17 @@ export default function Stats() {
match: (option, query) => matchExercise(matcherOf(option.value), query),
}} />
</div>
- {exOpts.length > 1 && <Segmented className="seg-range" value={onMax ? 'max' : onEff ? 'effort' : onE1 ? 'e1rm' : onSets ? 'sets' : 'top'} onChange={setExMetric} options={exOpts} />}
+ {exOpts.length > 1 && <Segmented className="seg-range" value={onRel ? 'bodyweight' : onMax ? 'max' : onEff ? 'effort' : onE1 ? 'e1rm' : onSets ? 'sets' : 'top'} onChange={setExMetric} options={exOpts} />}
<Segmented className="seg-range" value={exRange} onChange={setExRange} options={rangeOptions()} />
+ {onRel && canRelE1 && canRelTop && <Segmented className="seg-range" value={relUsed} onChange={setRelBasis}
+ options={[{ value: 'e1rm', label: t('Est. 1RM') }, { value: 'top', label: t('Top set') }]} />}
<div className="chart">
{rangeTooShort
? <div className="empty small">{t('Fewer than two workouts in this period. Pick a longer one.')}</div>
: onSets
? <LineChart points={perSetChart.anchors} series={perSetChart.series} h={150} unit={perSet.metric === 'reps' ? t('reps') : S.unit} />
+ : onRel
+ ? <LineChart points={relChartPts} h={150} unit="% BW" />
: onMax
? <LineChart points={maxChartPts} h={150} unit={t('reps')} color="var(--blue)" />
: onEff
@@ -800,9 +825,17 @@ export default function Stats() {
<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, speedUnit)).join(' ')}</span></div>)}</div>
<div className="small dim" style={{ marginTop: 8 }}>
- {onSets ? (perSet.metric === 'reps' ? t('Reps in each working set, one line per set number') : t('Estimated 1RM of each working set, one line per set number')) : onMax ? <>{t('Most reps in a Max set per workout')} · {t('Best:')}{' '}<b className="accent">{maxBest} {t('reps')}</b></> : onEff ? t('Average effort per workout') : onE1 ? t('Estimated 1RM per workout') : curCardio ? t('Top speed per workout') : curTimed ? t('Longest hold per workout') : repsOnly ? t('Most reps in a set per workout') : t('Best set weight per workout')}
- {onEff || onMax || onSets ? '' : <> · {t('Best:')}{' '}<b className="accent">{fmtNum(onE1 ? e1Best.est : exBest)} {onE1 ? S.unit : exUnit}</b></>}
+ {onSets ? (perSet.metric === 'reps' ? t('Reps in each working set, one line per set number') : t('Estimated 1RM of each working set, one line per set number')) : onRel ? (relUsed === 'top' ? t('Heaviest set as a share of body weight, per workout') : t('Estimated 1RM as a share of body weight, per workout')) : onMax ? <>{t('Most reps in a Max set per workout')} · {t('Best:')}{' '}<b className="accent">{maxBest} {t('reps')}</b></> : onEff ? t('Average effort per workout') : onE1 ? t('Estimated 1RM per workout') : curCardio ? t('Top speed per workout') : curTimed ? t('Longest hold per workout') : repsOnly ? t('Most reps in a set per workout') : t('Best set weight per workout')}
+ {onRel ? <> · {t('Best:')}{' '}<b className="accent">{fmtNum(Math.max(0, ...relPts.map(p => p.y * 100)))} % BW</b></>
+ : onEff || onMax || onSets ? '' : <> · {t('Best:')}{' '}<b className="accent">{fmtNum(onE1 ? e1Best.est : exBest)} {onE1 ? S.unit : exUnit}</b></>}
</div>
+ {onRel && !rangeTooShort && (() => {
+ const inRange = relPts.filter(p => p.t >= exFrom)
+ const first = inRange[0], last = inRange[inRange.length - 1]
+ return <div className="small dim" style={{ marginTop: 4 }}>
+ {t('Body weight over this period: {0} → {1}. Bodyweight and assisted exercises count your body weight as part of the load.', fmtNum(first.bw) + ' ' + S.unit, fmtNum(last.bw) + ' ' + S.unit)}
+ </div>
+ })()}
{onSets && (perSet.drop || perSet.hidden > 0) && <div className="small dim" style={{ marginTop: 4 }}>
{perSet.drop && t('Where you most often drop off: set {0} ({1} of {2} workouts)', perSet.drop.n, perSet.drop.count, perSet.drop.of)}
{perSet.drop && perSet.hidden > 0 ? ' · ' : ''}
@@ -811,7 +844,7 @@ export default function Stats() {
{onE1 && <div className="small dim" style={{ marginTop: 4 }}>
{t('Best estimate from {0} on {1}. An estimate, not a tested max.', fmtNum(e1Best.w) + ' ' + S.unit + ' × ' + e1Best.r, fmtDate(e1Best.d, true))}
</div>}
- {!onEff && !onE1 && !onMax && !onSets && showEff && <div className="small dim" style={{ marginTop: 4 }}>
+ {!onEff && !onE1 && !onMax && !onSets && !onRel && showEff && <div className="small dim" style={{ marginTop: 4 }}>
{t('A fuller dot means less left in the tank. The same weight at a lower {0} is progress the line alone doesn’t show.', hd)}
</div>}
</> : <div className="muted small">{t('Finish your first workout and your progress curves will show up here.')}</div>}