/** * 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); }
/** * Init data */ protected function initData() { $Zones = $this->computeZones(); $Pace = new Pace(0, 0, $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' => '< ' . $hf . ' %', 'time' => $Info['time'], 'distance' => $Info['distance'], 'average' => $Pace->value() > 0 ? $Pace->valueWithAppendix() : '-'); } } }
/** * @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); }
/** * @param int $num * @param enum $paceUnit */ protected function manipulateData($num, $paceUnit) { $paceInTime = $paceUnit == APace::MIN_PER_KM || $paceUnit == APace::MIN_PER_100M || $paceUnit == APace::MIN_PER_500M; $pace = new APace(0, 1, $paceUnit); foreach ($this->Data as $key => $val) { if ($num > 35) { $this->Labels[$key] = array($key, round($this->Labels[$key], 1)); } elseif ($num >= 20) { $this->Labels[$key] = array($key, number_format($this->Labels[$key], 1, '.', '')); } elseif ($num > 10) { $this->Labels[$key] = array($key, $this->Labels[$key] . 'k'); } else { $this->Labels[$key] = array($key, $this->Labels[$key] . ' km'); } $pace->setTime($val); if ($paceInTime) { $this->Data[$key] = 1000 * $pace->secondsPerKm(); if ($paceUnit == APace::MIN_PER_100M) { $this->Data[$key] /= 10; } elseif ($paceUnit == APace::MIN_PER_500M) { $this->Data[$key] /= 2; } } else { $this->Data[$key] = (double) str_replace(',', '.', $pace->value()); } } $this->Plot->Data[] = array('label' => $this->title, 'data' => $this->Data); }