|
11 | 11 | $file = '/fit_files/power-analysis.fit'; |
12 | 12 |
|
13 | 13 | $options = [ |
14 | | - // 'fixData' => ['all'], |
15 | | - 'units' => ['metric'] |
| 14 | + // 'fixData' => ['all'], |
| 15 | + // 'units' => ['metric'] |
16 | 16 | ]; |
17 | 17 | $pFFA = new adriangibbons\phpFITFileAnalysis(__DIR__ . $file, $options); |
18 | 18 |
|
|
28 | 28 | $date_s = $date_s + $json_tz->rawOffset + $json_tz->dstOffset; |
29 | 29 | } |
30 | 30 | $date->setTimestamp($date_s); |
31 | | - |
| 31 | + |
| 32 | + $ftp = 329; |
32 | 33 | $hr_metrics = $pFFA->hrMetrics(52, 185, 172, 'male'); |
33 | | - $power_metrics = $pFFA->powerMetrics(312); |
| 34 | + $power_metrics = $pFFA->powerMetrics($ftp); |
34 | 35 | $criticalPower = $pFFA->criticalPower([2,3,5,10,30,60,120,300,600,1200,3600,7200,10800,18000]); |
35 | 36 | $power_histogram = $pFFA->powerHistogram(); |
36 | | - $power_table = $pFFA->powerPartioned(312); |
37 | | - $power_pie_chart = $pFFA->partitionData('power', $pFFA->powerZones(312), true, false); |
| 37 | + $power_table = $pFFA->powerPartioned($ftp); |
| 38 | + $power_pie_chart = $pFFA->partitionData('power', $pFFA->powerZones($ftp), true, false); |
| 39 | + $quad_plot = $pFFA->quadrantAnalysis(0.175, $ftp); |
38 | 40 | } catch (Exception $e) { |
39 | 41 | echo 'caught exception: '.$e->getMessage(); |
40 | 42 | die(); |
|
152 | 154 | </div> |
153 | 155 | </div> |
154 | 156 | </div> |
| 157 | + |
| 158 | + <div class="panel panel-default"> |
| 159 | + <div class="panel-heading"> |
| 160 | + <h3 class="panel-title"><i class="fa fa-line-chart"></i> Quadrant Analysis <small>Circumferential Pedal Velocity (x-axis) vs Average Effective Pedal Force (y-axis)</small></h3> |
| 161 | + </div> |
| 162 | + <div class="panel-body"> |
| 163 | + <div id="quadrant_analysis" style="width:100%; height:600px"></div> |
| 164 | + </div> |
| 165 | + </div> |
| 166 | + |
155 | 167 | </div> |
156 | 168 | </div> |
157 | 169 | </div> |
@@ -370,6 +382,108 @@ function labelFormatter(label, series) { |
370 | 382 | $("#power_zones_table tr").removeClass("danger"); |
371 | 383 | $("#" + obj.series.data[0][1].toFixed(1).toString().replace(/\./g, '-') ).addClass("danger"); |
372 | 384 | }); |
| 385 | + |
| 386 | +var quad = [<?php |
| 387 | +$plottmp = []; |
| 388 | +foreach ($quad_plot['plot'] as $v) { |
| 389 | + $plottmp[] = '[' . $v[0] . ', ' . $v[1] . ']'; |
| 390 | +} |
| 391 | +echo implode(', ', $plottmp); ?>]; |
| 392 | + |
| 393 | + var lo = [<?php |
| 394 | +unset ($plottmp); |
| 395 | +$plottmp = []; |
| 396 | +foreach ($quad_plot['ftp-25w'] as $v) { |
| 397 | + $plottmp[] = '[' . $v[0] . ', ' . $v[1] . ']'; |
| 398 | +} |
| 399 | +echo implode(', ', $plottmp); ?>]; |
| 400 | + |
| 401 | + var at = [<?php |
| 402 | +unset ($plottmp); |
| 403 | +$plottmp = []; |
| 404 | +foreach ($quad_plot['ftp'] as $v) { |
| 405 | + $plottmp[] = '[' . $v[0] . ', ' . $v[1] . ']'; |
| 406 | +} |
| 407 | +echo implode(', ', $plottmp); ?>]; |
| 408 | + var hi = [<?php |
| 409 | +unset ($plottmp); |
| 410 | +$plottmp = []; |
| 411 | +foreach ($quad_plot['ftp+25w'] as $v) { |
| 412 | + $plottmp[] = '[' . $v[0] . ', ' . $v[1] . ']'; |
| 413 | +} |
| 414 | +echo implode(', ', $plottmp); ?>]; |
| 415 | + |
| 416 | + var markings = [ |
| 417 | + { |
| 418 | + color: "black", |
| 419 | + lineWidth: 1, |
| 420 | + xaxis: { |
| 421 | + from: <?php echo $quad_plot['cpv_threshold']; ?>, |
| 422 | + to: <?php echo $quad_plot['cpv_threshold']; ?> |
| 423 | + } |
| 424 | + }, |
| 425 | + { |
| 426 | + color: "black", |
| 427 | + lineWidth: 1, |
| 428 | + yaxis: { |
| 429 | + from: <?php echo $quad_plot['aepf_threshold']; ?>, |
| 430 | + to: <?php echo $quad_plot['aepf_threshold']; ?> |
| 431 | + } |
| 432 | + } |
| 433 | + ]; |
| 434 | + |
| 435 | + var quadrant_analysis_options = { |
| 436 | + xaxis: { |
| 437 | + label: 'circumferential pedal velocity', |
| 438 | + tickFormatter: function(label, series) { return label + ' m/s'; } |
| 439 | + }, |
| 440 | + yaxis: { |
| 441 | + max: 400, |
| 442 | + label: 'average effective pedal force', |
| 443 | + tickSize: 50, |
| 444 | + tickFormatter: function(label, series) { |
| 445 | + if(label == 0) return ""; |
| 446 | + return label + ' N'; |
| 447 | + } |
| 448 | + }, |
| 449 | + grid: { |
| 450 | + borderWidth: { |
| 451 | + top: 0, |
| 452 | + right: 0, |
| 453 | + bottom: 0, |
| 454 | + left: 0 |
| 455 | + }, |
| 456 | + markings: markings |
| 457 | + }, |
| 458 | + legend: { show: false } |
| 459 | + }; |
| 460 | + |
| 461 | + var plot_qa = $.plot($("#quadrant_analysis"), [ |
| 462 | + { |
| 463 | + data : quad, |
| 464 | + points : { show: true, radius: 0.25, fill : true, fillColor: "#058DC7" } |
| 465 | + }, |
| 466 | + { |
| 467 | + data : at, |
| 468 | + color: "blue", |
| 469 | + lines: { show: true, lineWidth: 0.5 } |
| 470 | + }, |
| 471 | + { |
| 472 | + data : lo, |
| 473 | + color: "red", |
| 474 | + lines: { show: true, lineWidth: 0.5 } |
| 475 | + }, |
| 476 | + { |
| 477 | + data : hi, |
| 478 | + color: "green", |
| 479 | + lines: { show: true, lineWidth: 0.5 } |
| 480 | + } |
| 481 | + ], quadrant_analysis_options); |
| 482 | + |
| 483 | + $("#quadrant_analysis").append("<span style='background-color: #fafafa; top: " + (plot_qa.height() / 2 - 40) + "px; color: #333; text-align: center; font-size: 12px; border: 1px solid #ddd; border-radius: 5px; padding: 3px 7px; position: absolute; left: " + (plot_qa.width() - 140) + "px'><strong>High Force / High Velocity</strong><br><?php echo $quad_plot['quad_percent']['hf_hv']; ?> %</span>"); |
| 484 | + $("#quadrant_analysis").append("<span style='background-color: #fafafa; top: " + (plot_qa.height() / 2 - 40) + "px; color: #333; text-align: center; font-size: 12px; border: 1px solid #ddd; border-radius: 5px; padding: 3px 7px; position: absolute; left: 50px'><strong>High Force / Low Velocity</strong><br><?php echo $quad_plot['quad_percent']['hf_lv']; ?> %</span>"); |
| 485 | + $("#quadrant_analysis").append("<span style='background-color: #fafafa; top: " + (plot_qa.height() / 2 + 15) + "px; color: #333; text-align: center; font-size: 12px; border: 1px solid #ddd; border-radius: 5px; padding: 3px 7px; position: absolute; left: 50px'><strong>Low Force / Low Velocity</strong><br><?php echo $quad_plot['quad_percent']['lf_lv']; ?> %</span>"); |
| 486 | + $("#quadrant_analysis").append("<span style='background-color: #fafafa; top: " + (plot_qa.height() / 2 + 15) + "px; color: #333; text-align: center; font-size: 12px; border: 1px solid #ddd; border-radius: 5px; padding: 3px 7px; position: absolute; left: " + (plot_qa.width() - 140) + "px'><strong>Low Force / High Velocity</strong><br><?php echo $quad_plot['quad_percent']['lf_hv']; ?> %</span>"); |
373 | 487 | }); |
374 | 488 | </script> |
375 | 489 | </body> |
|
0 commit comments