Beispiel #1
0
 /**
  * Load data
  * @param \Runalyze\View\Activity\Context $context
  */
 protected function loadData(Activity\Context $context)
 {
     if (!$context->trackdata()->has(Trackdata\Object::DISTANCE) || !$context->trackdata()->has(Trackdata\Object::TIME)) {
         $this->Plot->raiseError(__('No GPS-data available. Can\\\'t compute laps.'));
         return;
     }
     $RawData = $this->computeRounds($context);
     $num = count($RawData);
     $Pace = new PaceObject(0, 1);
     $Pace->setUnit($this->PaceUnit);
     foreach ($RawData as $key => $val) {
         $km = $key + 1;
         if ($num < 30) {
             $label = $km;
         } elseif ($num < 50) {
             $label = $km % 2 == 1 && $km > 0 ? $km : '';
         } elseif ($num < 100) {
             $label = $km % 5 == 0 && $km > 0 ? $km : '';
         } else {
             $label = $km % 10 == 0 && $km > 0 ? $km : '';
         }
         $this->Labels[$key] = array($key, $label);
         $Pace->setDistance($val['km'])->setTime($val['s']);
         if ($this->PaceUnit->isTimeFormat()) {
             $this->Data[$key] = 1000 * round($Pace->secondsPerKm() * $this->PaceUnit->factorForUnit());
         } else {
             $this->Data[$key] = (double) str_replace(',', '.', $Pace->value());
         }
     }
     $avgPace = new PaceObject($context->activity()->duration(), $context->activity()->distance());
     $this->achievedPace = $avgPace->secondsPerKm();
     $this->Plot->Data[] = array('label' => $this->title, 'data' => $this->Data);
 }
Beispiel #2
0
 /**
  * Display rounds
  */
 protected function displayTable()
 {
     $this->DemandedPace->setUnit($this->Context->sport()->paceUnit());
     $Table = new Table($this->Laps, $this->DemandedTime, $this->DemandedPace, $this->Context->sport()->id() == Configuration::General()->runningSport());
     if ($this->LapDistance > 0) {
         $Table->setAverage($this->Context->dataview()->pace(), new Duration($this->Context->trackdata()->totalTime() / $this->Context->trackdata()->totalDistance() * $this->LapDistance));
     } else {
         $Table->setAverage($this->Context->dataview()->pace());
     }
     $Table->display();
 }
 /**
  * Init data
  */
 protected function initData()
 {
     $Zones = $this->computeZones();
     $Pace = new Pace(0, 0);
     $Pace->setUnit($this->Context->sport()->paceUnit());
     foreach ($Zones as $hf => $Info) {
         if ($Info['time'] > parent::MINIMUM_TIME_IN_ZONE) {
             $Pace->setTime($Info['time']);
             $Pace->setDistance($Info['distance']);
             $this->Data[] = array('zone' => '&lt;&nbsp;' . $hf . '&nbsp;&#37;', 'time' => $Info['time'], 'distance' => $Info['distance'], 'average' => $Pace->value() > 0 ? $Pace->valueWithAppendix() : '-');
         }
     }
 }
 /**
  * Init data
  */
 protected function initData()
 {
     $this->PaceUnit = $this->Context->sport()->paceUnit();
     $Zones = $this->computeZones();
     $Pace = new Pace(0, 1);
     $Pace->setUnit($this->PaceUnit);
     $HR = new HeartRate(0, Runalyze\Context::Athlete());
     foreach ($Zones as $paceInSeconds => $Info) {
         if ($Info['time'] > parent::MINIMUM_TIME_IN_ZONE) {
             $Pace->setTime($paceInSeconds);
             $HR->setBPM($Info['time'] > 0 ? $Info['hr'] / $Info['time'] : 0);
             $this->Data[] = array('zone' => $paceInSeconds == 0 ? __('faster') : '&gt; ' . $Pace->valueWithAppendix(), 'time' => $Info['time'], 'distance' => $Info['distance'], 'average' => $HR->asBPM() > 0 ? $HR->string() : '-');
         }
     }
 }
Beispiel #5
0
 /**
  * Init data
  * @param \Runalyze\View\Activity\Context $context
  */
 protected function initData(Activity\Context $context)
 {
     $this->PaceUnit = $context->sport()->paceUnit();
     $this->SplitsAreNotComplete = $this->splitsAreNotComplete($context);
     $this->loadData($context);
     if (!empty($this->Data) && $this->PaceUnit->isTimeFormat()) {
         $max = Helper::ceilFor(max($this->Data), 30000);
         $this->Plot->setYAxisTimeFormat('%M:%S');
     } else {
         $max = ceil(max($this->Data));
         $Pace = new PaceObject(0, 1);
         $Pace->setUnit($this->PaceUnit);
         $this->Plot->addYUnit(1, str_replace('&nbsp;', '', $Pace->appendix()), 1);
     }
     $this->Plot->setYLimits(1, 0, $max, false);
     $this->Plot->setXLabels($this->Labels);
     $this->Plot->showBars(true);
     $this->Plot->setYTicks(1, null);
     $this->Plot->Options['xaxis']['show'] = true;
     // force to show xaxis-labels, even if no time or distance array is given
     $this->addAnnotations();
 }
Beispiel #6
0
 /**
  * @param int $num
  */
 protected function manipulateData($num)
 {
     $distanceUnit = \Runalyze\Configuration::General()->distanceUnitSystem()->distanceUnit();
     $Pace = new PaceObject(0, 1);
     $Pace->setUnit($this->PaceUnit);
     foreach ($this->Data as $key => $val) {
         if ($num > 35) {
             $this->Labels[$key] = array($key, round($this->Labels[$key], 1));
         } elseif ($num >= 15) {
             $this->Labels[$key] = array($key, number_format($this->Labels[$key], 1, '.', ''));
         } elseif ($num > 10) {
             $this->Labels[$key] = array($key, $this->Labels[$key] . $distanceUnit);
         } else {
             $this->Labels[$key] = array($key, $this->Labels[$key] . ' ' . $distanceUnit);
         }
         $Pace->setTime($val);
         if ($this->PaceUnit->isTimeFormat()) {
             $this->Data[$key] = 1000 * round($Pace->secondsPerKm() * $this->PaceUnit->factorForUnit());
         } else {
             $this->Data[$key] = (double) str_replace(',', '.', $Pace->value());
         }
     }
     $this->Plot->Data[] = array('label' => $this->title, 'data' => $this->Data);
 }
    /**
     * Display the table with general records
     */
    private function displayRekorde()
    {
        foreach ($this->rekorde as $rekord) {
            echo '<table class="fullwidth zebra-style">';
            echo '<thead><tr><th colspan="11" class="l">' . $rekord['name'] . '</th></tr></thead>';
            echo '<tbody>';
            $output = false;
            $sports = DB::getInstance()->query($rekord['sportquery'])->fetchAll();
            $Request = DB::getInstance()->prepare($rekord['datquery']);
            foreach ($sports as $sportData) {
                $Request->bindValue('sportid', $sportData['id']);
                $Request->execute();
                $data = $Request->fetchAll();
                if (!empty($data)) {
                    $Sport = new Sport\Object($sportData);
                    $output = true;
                    echo '<tr class="r">';
                    echo '<td class="b l">' . $Sport->icon()->code() . ' ' . $Sport->name() . '</td>';
                    $j = 0;
                    foreach ($data as $j => $dat) {
                        if ($rekord['speed']) {
                            $Pace = new Pace($dat['s'], $dat['distance']);
                            $Pace->setUnit($Sport->paceUnit());
                            $code = $Pace->valueWithAppendix();
                        } else {
                            $code = $dat['distance'] != 0 ? Distance::format($dat['distance']) : Duration::format($dat['s']);
                        }
                        echo '<td class="small"><span title="' . date("d.m.Y", $dat['time']) . '">
								' . Ajax::trainingLink($dat['id'], $code) . '
							</span></td>';
                    }
                    for (; $j < 9; $j++) {
                        echo HTML::emptyTD();
                    }
                    echo '</tr>';
                }
            }
            if (!$output) {
                echo '<tr><td colspan="11"><em>' . __('No data available') . '</em></td></tr>';
            }
            echo '</tbody>';
            echo '</table>';
        }
    }