Exemple #1
0
 /**
  * Determine correct x axis
  * @param \Runalyze\View\Activity\Context $context
  */
 protected function determineXAxis(Activity\Context $context)
 {
     if ($context->hasTrackdata()) {
         $totalTime = 1000 * $context->trackdata()->totalTime();
         if ($context->hrv()->num() == $context->trackdata()->num()) {
             $this->XAxisData = array_map(function ($value) {
                 return 1000 * $value;
             }, $context->trackdata()->time());
         } else {
             $correctTime = abs(array_sum($context->hrv()->data()) - $totalTime) > 0.005 * $totalTime;
             $time = 0;
             foreach ($context->hrv()->data() as $ms) {
                 $time += $correctTime && $ms < 1000 ? 1000 : $ms;
                 $this->XAxisData[] = $time;
             }
             if ($correctTime && abs($time - $totalTime) > 0.01 * $totalTime) {
                 $this->XAxisData = array();
             }
         }
     }
 }