Exemple #1
0
 /**
  * Add annotations
  */
 protected function addAnnotations()
 {
     if ($this->demandedPace > 0) {
         $demandedPace = $this->PaceUnit->rawValue($this->demandedPace);
         if ($this->PaceUnit->isTimeFormat()) {
             $demandedPace *= 1000;
         }
         $this->Plot->addThreshold("y", round($demandedPace), 'rgb(180,0,0)');
         //$this->Plot->addAnnotation(count($Data)-1, round($demandedPace), 'Soll: '.$this->PaceUnit->format($this->demandedPace), -10, -7);
     }
     if ($this->achievedPace > 0) {
         $achievedPace = $this->PaceUnit->rawValue($this->achievedPace);
         if ($this->PaceUnit->isTimeFormat()) {
             $achievedPace *= 1000;
         }
         $this->Plot->addThreshold("y", round($achievedPace), 'rgb(0,180,0)');
         $this->Plot->addAnnotation(0, round($achievedPace), 'ø ' . $this->PaceUnit->format($this->achievedPace), -40, -7);
     }
 }
 /**
  * @param int $paceInSeconds
  * @return int
  */
 protected function zoneFor($paceInSeconds)
 {
     if ($paceInSeconds == 0) {
         return 0;
     }
     if ($this->PaceUnit->isDecimalFormat()) {
         $dividend = $this->PaceUnit->dividendForUnit();
         return $paceInSeconds > $dividend ? 0 : $dividend / floor($dividend / $paceInSeconds);
     }
     $factor = $this->PaceUnit->factorForUnit();
     return round(30 * floor($factor * $paceInSeconds / 30) / $factor);
 }
Exemple #3
0
 /**
  * Compare
  * Both pace objects must have the same unit and the unit must be comparable.
  * @param \Runalyze\Activity\Pace $other
  * @param boolean $raw [optional]
  * @throws \InvalidArgumentException
  * @return string
  */
 public function compareTo(Pace $other, $raw = false)
 {
     if ($this->unitEnum() != $other->unitEnum()) {
         throw new \InvalidArgumentException('Pace objects must have the same unit.');
     }
     if ($this->secondsPerKm() == 0 || $other->secondsPerKm() == 0) {
         return '';
     }
     $comparisonInSecondsPerKm = $this->UnitObject->compare($this->secondsPerKm(), $other->secondsPerKm());
     $isPositive = $comparisonInSecondsPerKm >= 0;
     if ($comparisonInSecondsPerKm == 0 && $this->UnitObject->isTimeFormat()) {
         return $this->formatComparison('0:00', $isPositive, $raw);
     }
     return $this->formatComparison($this->UnitObject->format(abs($comparisonInSecondsPerKm)), $isPositive, $raw);
 }
Exemple #4
0
 /**
  * Add to plot
  * @param \Plot $Plot
  * @param int $yAxis
  * @param boolean $addAnnotations [optional]
  */
 public function addTo(\Plot &$Plot, $yAxis, $addAnnotations = true)
 {
     if (empty($this->Data)) {
         return;
     }
     parent::addTo($Plot, $yAxis, $addAnnotations);
     if (!$this->paceUnit->isTimeFormat()) {
         return;
     }
     $Plot->setYAxisTimeFormat('%M:%S', $yAxis);
     $min = min($this->Data);
     $max = max($this->Data);
     $setLimits = false;
     $autoscale = true;
     if (Configuration::ActivityView()->ignorePaceOutliers() && $max - $min > 2 * 60 * 1000) {
         $setLimits = true;
         $num = count($this->Data);
         $sorted = $this->Data;
         sort($sorted);
         $min = 10 * 1000 * floor($sorted[round(self::$CUT_OUTLIER_PERCENTAGE / 2 / 100 * $num)] / 10 / 1000);
         $max = 10 * 1000 * ceil($sorted[round((1 - self::$CUT_OUTLIER_PERCENTAGE / 2 / 100) * $num) - 1] / 10 / 1000);
     }
     if ($max > 50 * 60 * 1000) {
         $setLimits = true;
         $max = 50 * 60 * 1000;
     }
     if (Configuration::ActivityView()->paceAxisType()->valueAsString() == PaceAxisType::AS_SPEED) {
         $LimitMin = Configuration::ActivityView()->paceYaxisMinimum();
         if (!$LimitMin->automatic()) {
             $min = $LimitMin->value() * 1000;
         }
         $this->setYAxisForReversePace($Plot, $yAxis, $min);
     } else {
         $LimitMin = Configuration::ActivityView()->paceYaxisMinimum();
         $LimitMax = Configuration::ActivityView()->paceYaxisMaximum();
         if (!$LimitMin->automatic() || !$LimitMax->automatic()) {
             $setLimits = true;
             $autoscale = false;
             if (!$LimitMin->automatic() && $min < 1000 * $LimitMin->value()) {
                 $min = 1000 * $LimitMin->value();
             } else {
                 $min = 60 * 1000 * floor($min / 60 / 1000);
             }
             if (!$LimitMax->automatic() && $max > 1000 * $LimitMax->value()) {
                 $max = 1000 * $LimitMax->value();
             } else {
                 $max = 60 * 1000 * floor($max / 60 / 1000);
             }
         }
         if ($setLimits) {
             $Plot->setYLimits($yAxis, $min, $max, $autoscale);
             $Plot->setYAxisLabels($yAxis, null);
         }
     }
     switch (Configuration::ActivityView()->paceAxisType()->valueAsString()) {
         case PaceAxisType::AS_SPEED:
             $Plot->setYAxisPaceReverse($yAxis);
             break;
         case PaceAxisType::REVERSE:
             $Plot->setYAxisReverse($yAxis);
             break;
     }
 }
Exemple #5
0
 /**
  * @param \Runalyze\Activity\PaceUnit\AbstractUnit $Unit
  * @return string
  */
 public function asUnit(PaceUnit\AbstractUnit $Unit)
 {
     return $Unit->format($this->secondsPerKm());
 }