/** * Show pie chart for all of the aircraft flown * by a certain pilot. Outputs image, unless $ret == true, * then it returns the URL. */ public static function PilotAircraftFlownGraph($pilotid, $ret = false) { $stats = self::PilotAircraftFlownCounts($pilotid); if (!$stats) { return; } $data = ''; $labels = ''; foreach ($stats as $stat) { if ($stat->aircraft == '') { continue; } $data .= $stat->count . ','; $labels .= $stat->aircraft . '|'; } // remove that final lone char $data = substr($data, 0, strlen($data) - 1); $labels = substr($labels, 0, strlen($labels) - 1); $chart = new GoogleChart($data, 'pie'); $chart->dimensions = '350x200'; $chart->setLabels($labels); $url = $chart->draw(false); unset($chart); if ($ret == true) { return $url; } else { echo '<img src="' . $url . '" />'; } }
/** * Create a Google Chart chart */ protected function GoogleChart() { $chart = new GoogleChart(null, $this->type); # Loop through every set data //foreach($this->data as $set) //{ $values = @implode(',', $this->data); $labels = @implode('|', $this->labels); $chart->loadData($values); $chart->setLabels($labels, 'bottom'); //} $chart->dimensions = $this->x . 'x' . $this->y; return $chart->draw(false); }