Example #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();
             }
         }
     }
 }
Example #2
0
 /**
  * Init data
  * @param \Runalyze\View\Activity\Context $context
  */
 protected function initData(Activity\Context $context)
 {
     $Collector = new PointcareCollector($context->hrv());
     $this->Data = $Collector->data();
     if (empty($this->Data)) {
         return;
     }
     $this->Plot->Data[] = array('label' => __('Pointcare plot'), 'color' => 'rgb(0,0,0)', 'data' => $Collector->data());
     // TODO: ensure symmetric x-/y-axis
     // TODO: provide better tooltips
     $this->Plot->addYUnit(0, 'ms');
     $this->Plot->setXUnit('ms');
     $this->Plot->smoothing(false);
     $this->Plot->showPoints();
 }