Example #1
0
 /**
  * Compare new report to the main set of data and update each key accordingly
  * @return void
  */
 public function compareData()
 {
     foreach ($this->ga->report['totalsForAllResults'] as $key => $v) {
         if (isset($this->results[$key])) {
             $cls = '';
             $value = $this->results[$key]['value'];
             $compare = intval($v);
             if ($compare <= 0) {
                 $compare = 1;
             }
             $progression = round($value * 100 / $compare - 100, 1);
             if ($progression > 0) {
                 $progression = '+ ' . $progression;
                 $cls = 'up';
             } elseif ($progression < 0) {
                 $progression = str_replace('-', '- ', $progression);
                 $cls = 'down';
             }
             $this->results[$key]['progression'] = $progression;
             $this->results[$key]['progressionCls'] = $cls;
             $this->results[$key]['value'] = $this->ga->formatValue($key, $value);
         }
     }
     $this->formatOutput();
 }