function pie_chart ($data
{
$size=200;
$centerx = 100;
$centery = 100;
$circle_diameter = 180;
$image = image_create_alpha$size, $size);
$blackimagecolorallocatealpha$image, 0, 0, 0, 0);
$total = array_sum$data);
$n = 0;
$start = 0;
foreach ($data as $key => $value) {
$length = 360 * $value$total
$color = allocate_color$image, generate_graph_color$n++));
imagefilledarc$image, $centerx, $centery, $circle_diameter, $circle_diameter, round$start), round$start$length), $color, IMG_ARC_PIE);
$start += $length
}
imageellipse$image, $centerx, $centery, $circle_diameter, $circle_diameter, $black);
return $image
}