*
* Initialize the object and draw the pie. This would be the
* constructor in an ordinary OO scenario -- just that we haven't
* got constructors in PHP, now do we? ;-)
*
* RB 09.03.2006:
* - rearranged: please use indentation to seperate if/for blocks/statements!
* - modified to use draw_slices in stead of draw_slice
public init ( $w, $h, $d ) |
} } /* }}} */ $debug = 0; // Parse CGI GET vars and generate chart. // // Format is ?name=value,color&name2=value,color... // where name is set title, and color is in hex like (ffffff). // // Special names: title=[graph title], size=[WxH]. $vals = array(); $pie = new piechart(); foreach ($_GET as $key => $val) { if ($key == "title") { $heads[] = array($val, 4, "c"); } elseif ($key == "size") { list($w, $h) = explode("x", $val); } else { list($value, $color) = explode(",", $val); list($r, $g, $b) = $pie->hex2rgb($color); $vals[] = array($value, $key, $r, $g, $b); } } if (!$w or !$h) { $w = 400; $h = 300; } $pie->init($w, $h, $vals); $pie->draw_heading($heads); $pie->set_legend_percent(); $pie->display();
$dir[$key] = $row[1]; $usage[$key] = $row[2]; $limit[$key] = $row[3]; $hard[$key] = $row[4]; $used[$key] = $row[5]; } array_multisort($used, SORT_NUMERIC, SORT_DESC, $filearray); foreach ($filearray as $info) { list($red, $green, $blue) = $colors[$count]; $vals[] = array((int) $info[5], $info[1], $red, $green, $blue); if ($count == 15) { break; } $count++; } $heads = array(array("Top 16 Biggest Directory's", 4, "c"), array("on pugsly /export/home", 4, "c"), array("", 4, "c")); /* print "<pre>"; print_r($colors); print_r($vals); print "</pre>"; */ $pie = new piechart(); $pie->init(900, 700, $vals); $pie->draw_heading($heads); $pie->set_legend_percent(); $pie->display(); /* * Local Variables: * tab-width: 3 * End: */