</div> <?php foreach ($charts as $title => $data) { ?> <div class="block" style="float:left;margin-right:2em;"> <div class="hd"> <h2><?php echo $title; ?> </h2> </div> <div class="bd"> <?php $gc = new googleChart(implode(',', $data), 'pie'); $gc->setLabels(implode('|', array_keys($data))); $gc->draw(true); ?> </div> </div> <?php } ?> </div></div> </div> <div id="sidebar" class="yui-b"> </div> </div>
/** * 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 AircraftFlownGraph($ret = false) { //Select aircraft types $sql = 'SELECT a.name AS aircraft, COUNT(p.aircraft) AS count FROM ' . TABLE_PREFIX . 'pireps p, ' . TABLE_PREFIX . 'aircraft a WHERE p.aircraft = a.id GROUP BY a.name'; $stats = DB::get_results($sql); 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); if ($ret == true) { return $chart->draw(false); } else { echo '<img src="' . $chart->draw(false) . '" />'; } }