Spaces:
Running
Running
yeah
Browse files- index.html +19 -27
- src/components/charts.ts +24 -8
- src/style.css +45 -15
- src/types/index.ts +2 -0
- src/utils/metricAcwr.ts +40 -2
index.html
CHANGED
|
@@ -12,36 +12,28 @@
|
|
| 12 |
<div id="app">
|
| 13 |
<header>
|
| 14 |
<h1>Training Load Data Visualization</h1>
|
| 15 |
-
<
|
| 16 |
-
<
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
</header>
|
| 19 |
|
| 20 |
<main>
|
| 21 |
-
<
|
| 22 |
-
<h2>Upload Garmin Activities CSV</h2>
|
| 23 |
-
<div class="upload-container">
|
| 24 |
-
<div class="ftp-input-container">
|
| 25 |
-
<label for="ftp-input">
|
| 26 |
-
Functional Threshold Power (FTP)
|
| 27 |
-
</label>
|
| 28 |
-
<input type="number" id="ftp-input" value="343" min="0" step="1" placeholder="343" />
|
| 29 |
-
<span class="ftp-unit">Watts</span>
|
| 30 |
-
</div>
|
| 31 |
-
<div class="ftp-input-container">
|
| 32 |
-
<label for="target-acwr-input">
|
| 33 |
-
Target ACWR
|
| 34 |
-
</label>
|
| 35 |
-
<input type="number" id="target-acwr-input" value="1.3" min="0.5" max="3" step="0.1" placeholder="1.3" />
|
| 36 |
-
<span class="ftp-unit"></span>
|
| 37 |
-
</div>
|
| 38 |
-
<input type="file" id="csv-upload" accept=".csv" />
|
| 39 |
-
<label for="csv-upload" class="upload-label">
|
| 40 |
-
Choose CSV File
|
| 41 |
-
</label>
|
| 42 |
-
<div id="upload-status"></div>
|
| 43 |
-
</div>
|
| 44 |
-
</section>
|
| 45 |
|
| 46 |
<section id="filter-section" class="hidden">
|
| 47 |
<div class="filter-container" id="filter-container">
|
|
|
|
| 12 |
<div id="app">
|
| 13 |
<header>
|
| 14 |
<h1>Training Load Data Visualization</h1>
|
| 15 |
+
<div class="header-controls">
|
| 16 |
+
<div class="ftp-input-container">
|
| 17 |
+
<label for="ftp-input">FTP</label>
|
| 18 |
+
<input type="number" id="ftp-input" value="343" min="0" step="1" placeholder="343" />
|
| 19 |
+
<span class="ftp-unit">W</span>
|
| 20 |
+
</div>
|
| 21 |
+
<div class="ftp-input-container">
|
| 22 |
+
<label for="target-acwr-input">Target ACWR</label>
|
| 23 |
+
<input type="number" id="target-acwr-input" value="1.3" min="0.5" max="3" step="0.1" placeholder="1.3" />
|
| 24 |
+
</div>
|
| 25 |
+
<input type="file" id="csv-upload" accept=".csv" />
|
| 26 |
+
<label for="csv-upload" class="upload-label">
|
| 27 |
+
📁 Upload CSV
|
| 28 |
+
</label>
|
| 29 |
+
<button id="help-button" class="help-button" title="Help">
|
| 30 |
+
<span>?</span>
|
| 31 |
+
</button>
|
| 32 |
+
</div>
|
| 33 |
</header>
|
| 34 |
|
| 35 |
<main>
|
| 36 |
+
<div id="upload-status"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
<section id="filter-section" class="hidden">
|
| 39 |
<div class="filter-container" id="filter-container">
|
src/components/charts.ts
CHANGED
|
@@ -454,7 +454,7 @@ export function createDistanceChart(data: MetricACWRData): void {
|
|
| 454 |
'(km)',
|
| 455 |
'rgba(234, 179, 8, 0.8)'
|
| 456 |
);
|
| 457 |
-
updateTargetInfo('distance-target', data.targetTomorrowValue, 'km', data.targetACWR);
|
| 458 |
}
|
| 459 |
|
| 460 |
export function createDurationChart(data: MetricACWRData): void {
|
|
@@ -468,7 +468,7 @@ export function createDurationChart(data: MetricACWRData): void {
|
|
| 468 |
'(min)',
|
| 469 |
'rgba(234, 179, 8, 0.8)'
|
| 470 |
);
|
| 471 |
-
updateTargetInfo('duration-target', data.targetTomorrowValue, 'minutes', data.targetACWR);
|
| 472 |
}
|
| 473 |
|
| 474 |
export function createTSSChart(data: MetricACWRData): void {
|
|
@@ -482,7 +482,7 @@ export function createTSSChart(data: MetricACWRData): void {
|
|
| 482 |
'',
|
| 483 |
'rgba(234, 179, 8, 0.8)'
|
| 484 |
);
|
| 485 |
-
updateTargetInfo('tss-target', data.targetTomorrowValue, 'TSS', data.targetACWR);
|
| 486 |
}
|
| 487 |
|
| 488 |
export function createCaloriesChart(data: MetricACWRData): void {
|
|
@@ -496,16 +496,32 @@ export function createCaloriesChart(data: MetricACWRData): void {
|
|
| 496 |
'(kcal)',
|
| 497 |
'rgba(234, 179, 8, 0.8)'
|
| 498 |
);
|
| 499 |
-
updateTargetInfo('calories-target', data.targetTomorrowValue, 'kcal', data.targetACWR);
|
| 500 |
}
|
| 501 |
|
| 502 |
-
function updateTargetInfo(elementId: string, targetValue: number | null | undefined, unit: string, targetACWR: number | undefined): void {
|
| 503 |
const element = document.getElementById(elementId);
|
| 504 |
if (!element) return;
|
| 505 |
|
| 506 |
-
if (
|
| 507 |
-
|
| 508 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 509 |
element.classList.add('visible');
|
| 510 |
} else {
|
| 511 |
element.innerHTML = `<strong>ℹ️ Target for tomorrow:</strong> <span style="color: var(--secondary-color);">Need at least 28 days of data to calculate</span>`;
|
|
|
|
| 454 |
'(km)',
|
| 455 |
'rgba(234, 179, 8, 0.8)'
|
| 456 |
);
|
| 457 |
+
updateTargetInfo('distance-target', data.targetTomorrowValue, 'km', data.targetACWR, data.restTomorrowACWR);
|
| 458 |
}
|
| 459 |
|
| 460 |
export function createDurationChart(data: MetricACWRData): void {
|
|
|
|
| 468 |
'(min)',
|
| 469 |
'rgba(234, 179, 8, 0.8)'
|
| 470 |
);
|
| 471 |
+
updateTargetInfo('duration-target', data.targetTomorrowValue, 'minutes', data.targetACWR, data.restTomorrowACWR);
|
| 472 |
}
|
| 473 |
|
| 474 |
export function createTSSChart(data: MetricACWRData): void {
|
|
|
|
| 482 |
'',
|
| 483 |
'rgba(234, 179, 8, 0.8)'
|
| 484 |
);
|
| 485 |
+
updateTargetInfo('tss-target', data.targetTomorrowValue, 'TSS', data.targetACWR, data.restTomorrowACWR);
|
| 486 |
}
|
| 487 |
|
| 488 |
export function createCaloriesChart(data: MetricACWRData): void {
|
|
|
|
| 496 |
'(kcal)',
|
| 497 |
'rgba(234, 179, 8, 0.8)'
|
| 498 |
);
|
| 499 |
+
updateTargetInfo('calories-target', data.targetTomorrowValue, 'kcal', data.targetACWR, data.restTomorrowACWR);
|
| 500 |
}
|
| 501 |
|
| 502 |
+
function updateTargetInfo(elementId: string, targetValue: number | null | undefined, unit: string, targetACWR: number | undefined, restTomorrowACWR: number | null | undefined): void {
|
| 503 |
const element = document.getElementById(elementId);
|
| 504 |
if (!element) return;
|
| 505 |
|
| 506 |
+
if (targetACWR !== undefined) {
|
| 507 |
+
let html: string;
|
| 508 |
+
|
| 509 |
+
if (targetValue === null || targetValue === undefined) {
|
| 510 |
+
html = `<strong>💡 Target for tomorrow:</strong> <span style="color: var(--secondary-color);">Target ACWR of ${targetACWR} cannot be reached in one day</span>`;
|
| 511 |
+
} else if (targetValue === 0) {
|
| 512 |
+
html = `<strong>💡 Target for tomorrow:</strong> <span style="color: var(--secondary-color);">Rest day recommended to reach ACWR of ${targetACWR}</span>`;
|
| 513 |
+
} else {
|
| 514 |
+
const formattedValue = targetValue.toFixed(1);
|
| 515 |
+
html = `<strong>💡 Target for tomorrow:</strong> <span class="target-value">${formattedValue} ${unit}</span> <span style="color: var(--secondary-color);">to reach ACWR of ${targetACWR}</span>`;
|
| 516 |
+
}
|
| 517 |
+
|
| 518 |
+
// Add rest tomorrow information
|
| 519 |
+
if (restTomorrowACWR !== null && restTomorrowACWR !== undefined) {
|
| 520 |
+
const color = getACWRColor(restTomorrowACWR);
|
| 521 |
+
html += `<br><strong>😴 Rest tomorrow:</strong> <span style="color: ${color};">ACWR ${restTomorrowACWR.toFixed(2)}</span>`;
|
| 522 |
+
}
|
| 523 |
+
|
| 524 |
+
element.innerHTML = html;
|
| 525 |
element.classList.add('visible');
|
| 526 |
} else {
|
| 527 |
element.innerHTML = `<strong>ℹ️ Target for tomorrow:</strong> <span style="color: var(--secondary-color);">Need at least 28 days of data to calculate</span>`;
|
src/style.css
CHANGED
|
@@ -33,17 +33,30 @@ body {
|
|
| 33 |
header {
|
| 34 |
background-color: var(--card-bg);
|
| 35 |
border-bottom: 1px solid var(--border-color);
|
| 36 |
-
padding:
|
| 37 |
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
| 38 |
display: flex;
|
| 39 |
justify-content: space-between;
|
| 40 |
align-items: center;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
}
|
| 42 |
|
| 43 |
header h1 {
|
| 44 |
-
font-size: 1.
|
| 45 |
color: var(--primary-color);
|
| 46 |
font-weight: 700;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
}
|
| 48 |
|
| 49 |
.help-button {
|
|
@@ -252,7 +265,7 @@ header h1 {
|
|
| 252 |
main {
|
| 253 |
flex: 1;
|
| 254 |
padding: 2rem;
|
| 255 |
-
max-width:
|
| 256 |
margin: 0 auto;
|
| 257 |
width: 100%;
|
| 258 |
}
|
|
@@ -290,38 +303,40 @@ h2 {
|
|
| 290 |
.ftp-input-container {
|
| 291 |
display: flex;
|
| 292 |
align-items: center;
|
| 293 |
-
gap: 0.
|
| 294 |
-
padding:
|
| 295 |
background-color: var(--bg-color);
|
| 296 |
border-radius: 6px;
|
| 297 |
border: 1px solid var(--border-color);
|
| 298 |
}
|
| 299 |
|
| 300 |
.ftp-input-container label {
|
| 301 |
-
font-size: 0.
|
| 302 |
font-weight: 500;
|
| 303 |
color: var(--text-color);
|
| 304 |
white-space: nowrap;
|
| 305 |
}
|
| 306 |
|
| 307 |
-
#ftp-input
|
| 308 |
-
|
| 309 |
-
|
|
|
|
| 310 |
border: 1px solid var(--border-color);
|
| 311 |
border-radius: 4px;
|
| 312 |
-
font-size:
|
| 313 |
text-align: center;
|
| 314 |
background-color: var(--card-bg);
|
| 315 |
}
|
| 316 |
|
| 317 |
-
#ftp-input:focus
|
|
|
|
| 318 |
outline: none;
|
| 319 |
border-color: var(--primary-color);
|
| 320 |
-
box-shadow: 0 0 0
|
| 321 |
}
|
| 322 |
|
| 323 |
.ftp-unit {
|
| 324 |
-
font-size: 0.
|
| 325 |
color: var(--secondary-color);
|
| 326 |
font-weight: 500;
|
| 327 |
}
|
|
@@ -332,13 +347,15 @@ h2 {
|
|
| 332 |
|
| 333 |
.upload-label {
|
| 334 |
display: inline-block;
|
| 335 |
-
padding: 0.
|
| 336 |
background-color: var(--primary-color);
|
| 337 |
color: white;
|
| 338 |
border-radius: 6px;
|
| 339 |
cursor: pointer;
|
| 340 |
font-weight: 500;
|
|
|
|
| 341 |
transition: background-color 0.2s;
|
|
|
|
| 342 |
}
|
| 343 |
|
| 344 |
.upload-label:hover {
|
|
@@ -349,9 +366,10 @@ h2 {
|
|
| 349 |
font-size: 0.875rem;
|
| 350 |
color: var(--secondary-color);
|
| 351 |
min-height: 1.5rem;
|
| 352 |
-
max-width:
|
| 353 |
white-space: pre-wrap;
|
| 354 |
text-align: left;
|
|
|
|
| 355 |
}
|
| 356 |
|
| 357 |
#upload-status.success {
|
|
@@ -376,6 +394,9 @@ h2 {
|
|
| 376 |
padding: 1rem 2rem;
|
| 377 |
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
| 378 |
margin-bottom: 2rem;
|
|
|
|
|
|
|
|
|
|
| 379 |
}
|
| 380 |
|
| 381 |
#filter-container {
|
|
@@ -417,6 +438,14 @@ h2 {
|
|
| 417 |
#charts-section {
|
| 418 |
display: grid;
|
| 419 |
gap: 2rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 420 |
}
|
| 421 |
|
| 422 |
.chart-container {
|
|
@@ -463,6 +492,7 @@ h2 {
|
|
| 463 |
display: flex;
|
| 464 |
gap: 1.5rem;
|
| 465 |
flex-wrap: wrap;
|
|
|
|
| 466 |
}
|
| 467 |
|
| 468 |
.legend-item {
|
|
|
|
| 33 |
header {
|
| 34 |
background-color: var(--card-bg);
|
| 35 |
border-bottom: 1px solid var(--border-color);
|
| 36 |
+
padding: 1rem 2rem;
|
| 37 |
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
| 38 |
display: flex;
|
| 39 |
justify-content: space-between;
|
| 40 |
align-items: center;
|
| 41 |
+
gap: 2rem;
|
| 42 |
+
flex-wrap: wrap;
|
| 43 |
+
position: sticky;
|
| 44 |
+
top: 0;
|
| 45 |
+
z-index: 200;
|
| 46 |
}
|
| 47 |
|
| 48 |
header h1 {
|
| 49 |
+
font-size: 1.5rem;
|
| 50 |
color: var(--primary-color);
|
| 51 |
font-weight: 700;
|
| 52 |
+
white-space: nowrap;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
.header-controls {
|
| 56 |
+
display: flex;
|
| 57 |
+
align-items: center;
|
| 58 |
+
gap: 1rem;
|
| 59 |
+
flex-wrap: wrap;
|
| 60 |
}
|
| 61 |
|
| 62 |
.help-button {
|
|
|
|
| 265 |
main {
|
| 266 |
flex: 1;
|
| 267 |
padding: 2rem;
|
| 268 |
+
max-width: 100%;
|
| 269 |
margin: 0 auto;
|
| 270 |
width: 100%;
|
| 271 |
}
|
|
|
|
| 303 |
.ftp-input-container {
|
| 304 |
display: flex;
|
| 305 |
align-items: center;
|
| 306 |
+
gap: 0.5rem;
|
| 307 |
+
padding: 0.5rem 0.75rem;
|
| 308 |
background-color: var(--bg-color);
|
| 309 |
border-radius: 6px;
|
| 310 |
border: 1px solid var(--border-color);
|
| 311 |
}
|
| 312 |
|
| 313 |
.ftp-input-container label {
|
| 314 |
+
font-size: 0.75rem;
|
| 315 |
font-weight: 500;
|
| 316 |
color: var(--text-color);
|
| 317 |
white-space: nowrap;
|
| 318 |
}
|
| 319 |
|
| 320 |
+
#ftp-input,
|
| 321 |
+
#target-acwr-input {
|
| 322 |
+
width: 70px;
|
| 323 |
+
padding: 0.375rem 0.5rem;
|
| 324 |
border: 1px solid var(--border-color);
|
| 325 |
border-radius: 4px;
|
| 326 |
+
font-size: 0.875rem;
|
| 327 |
text-align: center;
|
| 328 |
background-color: var(--card-bg);
|
| 329 |
}
|
| 330 |
|
| 331 |
+
#ftp-input:focus,
|
| 332 |
+
#target-acwr-input:focus {
|
| 333 |
outline: none;
|
| 334 |
border-color: var(--primary-color);
|
| 335 |
+
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
|
| 336 |
}
|
| 337 |
|
| 338 |
.ftp-unit {
|
| 339 |
+
font-size: 0.75rem;
|
| 340 |
color: var(--secondary-color);
|
| 341 |
font-weight: 500;
|
| 342 |
}
|
|
|
|
| 347 |
|
| 348 |
.upload-label {
|
| 349 |
display: inline-block;
|
| 350 |
+
padding: 0.5rem 1rem;
|
| 351 |
background-color: var(--primary-color);
|
| 352 |
color: white;
|
| 353 |
border-radius: 6px;
|
| 354 |
cursor: pointer;
|
| 355 |
font-weight: 500;
|
| 356 |
+
font-size: 0.875rem;
|
| 357 |
transition: background-color 0.2s;
|
| 358 |
+
white-space: nowrap;
|
| 359 |
}
|
| 360 |
|
| 361 |
.upload-label:hover {
|
|
|
|
| 366 |
font-size: 0.875rem;
|
| 367 |
color: var(--secondary-color);
|
| 368 |
min-height: 1.5rem;
|
| 369 |
+
max-width: 100%;
|
| 370 |
white-space: pre-wrap;
|
| 371 |
text-align: left;
|
| 372 |
+
margin-bottom: 1rem;
|
| 373 |
}
|
| 374 |
|
| 375 |
#upload-status.success {
|
|
|
|
| 394 |
padding: 1rem 2rem;
|
| 395 |
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
| 396 |
margin-bottom: 2rem;
|
| 397 |
+
position: sticky;
|
| 398 |
+
top: 80px;
|
| 399 |
+
z-index: 100;
|
| 400 |
}
|
| 401 |
|
| 402 |
#filter-container {
|
|
|
|
| 438 |
#charts-section {
|
| 439 |
display: grid;
|
| 440 |
gap: 2rem;
|
| 441 |
+
grid-template-columns: 1fr;
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
/* Two-column layout for desktop */
|
| 445 |
+
@media (min-width: 1400px) {
|
| 446 |
+
#charts-section {
|
| 447 |
+
grid-template-columns: repeat(2, 1fr);
|
| 448 |
+
}
|
| 449 |
}
|
| 450 |
|
| 451 |
.chart-container {
|
|
|
|
| 492 |
display: flex;
|
| 493 |
gap: 1.5rem;
|
| 494 |
flex-wrap: wrap;
|
| 495 |
+
grid-column: 1 / -1;
|
| 496 |
}
|
| 497 |
|
| 498 |
.legend-item {
|
src/types/index.ts
CHANGED
|
@@ -24,5 +24,7 @@ export interface MetricACWRData {
|
|
| 24 |
acwr: (number | null)[]; // ACWR based on this metric
|
| 25 |
targetTomorrowValue?: number | null; // Value needed tomorrow to reach target ACWR of 1.3
|
| 26 |
targetACWR?: number; // The target ACWR value used for calculation
|
|
|
|
|
|
|
| 27 |
activitiesByDate?: Map<string, Activity[]>; // Activities grouped by date
|
| 28 |
}
|
|
|
|
| 24 |
acwr: (number | null)[]; // ACWR based on this metric
|
| 25 |
targetTomorrowValue?: number | null; // Value needed tomorrow to reach target ACWR of 1.3
|
| 26 |
targetACWR?: number; // The target ACWR value used for calculation
|
| 27 |
+
restTomorrowACWR?: number | null; // What ACWR would be with a rest day tomorrow
|
| 28 |
+
todayValue?: number | null; // Today's value for reference
|
| 29 |
activitiesByDate?: Map<string, Activity[]>; // Activities grouped by date
|
| 30 |
}
|
src/utils/metricAcwr.ts
CHANGED
|
@@ -169,9 +169,14 @@ export function calculateMetricACWR(
|
|
| 169 |
if (Math.abs(denominator) > 0.001) {
|
| 170 |
targetTomorrowValue = numerator / denominator;
|
| 171 |
|
| 172 |
-
//
|
|
|
|
| 173 |
if (targetTomorrowValue < 0) {
|
| 174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
}
|
| 176 |
} else {
|
| 177 |
// Special case: targetACWR ≈ 4, need different approach
|
|
@@ -180,6 +185,37 @@ export function calculateMetricACWR(
|
|
| 180 |
}
|
| 181 |
}
|
| 182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
return {
|
| 184 |
dates,
|
| 185 |
values,
|
|
@@ -188,6 +224,8 @@ export function calculateMetricACWR(
|
|
| 188 |
acwr,
|
| 189 |
targetTomorrowValue,
|
| 190 |
targetACWR: allDates.length >= 28 ? targetACWR : undefined,
|
|
|
|
|
|
|
| 191 |
activitiesByDate,
|
| 192 |
};
|
| 193 |
}
|
|
|
|
| 169 |
if (Math.abs(denominator) > 0.001) {
|
| 170 |
targetTomorrowValue = numerator / denominator;
|
| 171 |
|
| 172 |
+
// If negative and target ACWR < 1.0, set to 0 (rest day recommended)
|
| 173 |
+
// If negative and target ACWR >= 1.0, set to null (target unreachable)
|
| 174 |
if (targetTomorrowValue < 0) {
|
| 175 |
+
if (targetACWR < 1.0) {
|
| 176 |
+
targetTomorrowValue = 0;
|
| 177 |
+
} else {
|
| 178 |
+
targetTomorrowValue = null;
|
| 179 |
+
}
|
| 180 |
}
|
| 181 |
} else {
|
| 182 |
// Special case: targetACWR ≈ 4, need different approach
|
|
|
|
| 185 |
}
|
| 186 |
}
|
| 187 |
|
| 188 |
+
// Calculate what ACWR would be with a rest day tomorrow
|
| 189 |
+
let restTomorrowACWR: number | null = null;
|
| 190 |
+
|
| 191 |
+
if (allDates.length >= 28) {
|
| 192 |
+
// Calculate tomorrow's 7-day acute sum with rest (last 6 days + 0)
|
| 193 |
+
let tomorrowAcuteSum = 0;
|
| 194 |
+
for (let i = allDates.length - 6; i < allDates.length; i++) {
|
| 195 |
+
const checkDateStr = formatDateLocal(allDates[i]);
|
| 196 |
+
const val = dailyValues.get(checkDateStr) || 0;
|
| 197 |
+
tomorrowAcuteSum += val;
|
| 198 |
+
}
|
| 199 |
+
// Add 0 for rest day (no need to add)
|
| 200 |
+
|
| 201 |
+
// Calculate tomorrow's 28-day chronic sum with rest (last 27 days + 0)
|
| 202 |
+
let tomorrowChronicSum = 0;
|
| 203 |
+
for (let i = allDates.length - 27; i < allDates.length; i++) {
|
| 204 |
+
const checkDateStr = formatDateLocal(allDates[i]);
|
| 205 |
+
const val = dailyValues.get(checkDateStr) || 0;
|
| 206 |
+
tomorrowChronicSum += val;
|
| 207 |
+
}
|
| 208 |
+
// Add 0 for rest day (no need to add)
|
| 209 |
+
|
| 210 |
+
// Calculate ACWR with rest day
|
| 211 |
+
const tomorrowAcuteAvg = tomorrowAcuteSum / 7;
|
| 212 |
+
const tomorrowChronicAvg = tomorrowChronicSum / 28;
|
| 213 |
+
|
| 214 |
+
if (tomorrowChronicAvg > 0) {
|
| 215 |
+
restTomorrowACWR = tomorrowAcuteAvg / tomorrowChronicAvg;
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
return {
|
| 220 |
dates,
|
| 221 |
values,
|
|
|
|
| 224 |
acwr,
|
| 225 |
targetTomorrowValue,
|
| 226 |
targetACWR: allDates.length >= 28 ? targetACWR : undefined,
|
| 227 |
+
restTomorrowACWR: allDates.length >= 28 ? restTomorrowACWR : undefined,
|
| 228 |
+
todayValue: undefined,
|
| 229 |
activitiesByDate,
|
| 230 |
};
|
| 231 |
}
|