Skip to content

Commit f088cdb

Browse files
cagnuleinclaude
andcommitted
Fix ramp chart preview rendering as a vertical spike instead of a slope
Chart.js's `stepped: true` was hardcoded for every dataset in the chart renderer (pre-existing, unrelated to this PR). That's correct for series like resistance/cadence, whose points already encode sharp transitions via duplicate x values at interval boundaries, but it forces a step interpolation between a ramp's two distinct-x points too, turning the intended diagonal (fromW at start, toW at end) into a flat segment followed by a vertical jump at the very end - which is what showed up as a stray vertical line in the preview. Added a per-series `stepped` flag (default true, unchanged for resistance/cadence/etc.), set to false for the power series (bike and rower) since it's the only one that can carry a ramp. Flat (non-ramp) power segments look identical whether stepped or not, so this doesn't affect the non-ramp case. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent bff3827 commit f088cdb

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/inner_templates/workouteditor/workout-editor-app.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@
5555
bike: [
5656
{ key: 'resistance', label: () => t('workoutEditor.resistance', 'Resistance'), color: '#ab47bc', unit: () => 'lvl', axis: 'resistanceAxis', axisLabel: () => t('workoutEditor.resistance', 'Resistance'), axisPosition: 'left' },
5757
{ key: 'cadence', label: () => t('workoutEditor.cadence', 'Cadence'), color: '#29b6f6', unit: () => 'rpm', axis: 'cadenceAxis', axisLabel: () => t('workoutEditor.cadenceRpm', 'Cadence (rpm)'), axisPosition: 'right' },
58-
{ key: 'power', label: () => t('workoutEditor.power', 'Power'), color: '#ef6c00', unit: () => 'W', axis: 'powerAxis', axisLabel: () => t('workoutEditor.powerW', 'Power (W)'), axisPosition: 'left' }
58+
{ key: 'power', label: () => t('workoutEditor.power', 'Power'), color: '#ef6c00', unit: () => 'W', axis: 'powerAxis', axisLabel: () => t('workoutEditor.powerW', 'Power (W)'), axisPosition: 'left', stepped: false }
5959
],
6060
elliptical: [
6161
{ key: 'resistance', label: () => t('workoutEditor.resistance', 'Resistance'), color: '#7e57c2', unit: () => 'lvl', axis: 'resistanceAxis', axisLabel: () => t('workoutEditor.resistance', 'Resistance'), axisPosition: 'left' },
6262
{ key: 'inclination', label: () => t('workoutEditor.ramp', 'Ramp'), color: '#66bb6a', unit: () => '%', axis: 'inclineAxis', axisLabel: () => t('workoutEditor.rampPercent', 'Ramp (%)'), axisPosition: 'right' }
6363
],
6464
rower: [
65-
{ key: 'power', label: () => t('workoutEditor.power', 'Power'), color: '#fb8c00', unit: () => 'W', axis: 'powerAxis', axisLabel: () => t('workoutEditor.powerW', 'Power (W)'), axisPosition: 'left' },
65+
{ key: 'power', label: () => t('workoutEditor.power', 'Power'), color: '#fb8c00', unit: () => 'W', axis: 'powerAxis', axisLabel: () => t('workoutEditor.powerW', 'Power (W)'), axisPosition: 'left', stepped: false },
6666
{ key: 'cadence', label: () => t('workoutEditor.strokeRate', 'Stroke Rate'), color: '#26a69a', unit: () => 'spm', axis: 'cadenceAxis', axisLabel: () => t('workoutEditor.strokesPerMinute', 'Strokes/min'), axisPosition: 'right' }
6767
],
6868
jumprope: [],
@@ -1445,6 +1445,7 @@
14451445
axis: def.axis,
14461446
axisLabel: typeof def.axisLabel === 'function' ? def.axisLabel() : def.axisLabel,
14471447
axisPosition: def.axisPosition,
1448+
stepped: def.stepped !== false,
14481449
points: []
14491450
}));
14501451

src/inner_templates/workouteditor/workout-editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
backgroundColor: fillColor,
198198
unit: series.unit || '',
199199
yAxisID: series.axis || 'y',
200-
stepped: true,
200+
stepped: series.stepped !== false,
201201
borderWidth: series.lineWidth || 2,
202202
fill: Boolean(series.fill),
203203
tension: 0,

0 commit comments

Comments
 (0)