Har fundet et Cirkeldiagram kode til PHP, men jeg mangler % efter mine små frikanter.
Kode er fra
http://123login.dk/dexo/pie_diagram.php?ssHvad gør jeg forkert ?
<?php
$parts = array(40, 40, 20);//, 25);
$colors = array(
array(255, 0, 0),
array(0, 0, 255),
array(0,128,0),
array(255, 255, 0),
array(0, 0, 0)
);
// Parts in percentage
$red = 75;
$blue = 25;
$width = 200;
$height = 200;
$boxW = 15;
$boxH = 15;
$border = false;
$image = imageCreate($width, $height + sizeof($parts) * $boxH * 2);
imageColorAllocate($image, 255, 255, 255);
$centerX = $width / 2;
$centerY = $height / 2;
$d = 190;
foreach ($parts as $k => $v)
{
imageFilledArc($image, $centerX, $centerY, $width, $height,
$d, $d + $v * 3.6,
imageColorAllocate($image, $colors[$k][0], $colors[$k][1], $colors[$k][2]),
IMG_ARC_PIE);
$d += $v * 3.6;
// Draw box
imagefilledrectangle($image,
10,
$height + ($k + 1) * $boxH + $k * $boxH * 0.5,
10 + $boxW,
$height + ($k + 1) * $boxH + $boxH + $k * $boxH * 0.5,
imageColorAllocate($image, $colors[$k][0], $colors[$k][1], $colors[$k][2]));
if ($border)
imagerectangle($image,
10,
$height + ($k + 1) * $boxH + $k * $boxH * 0.5,
10 + $boxW,
$height + ($k + 1) * $boxH + $boxH + $k * $boxH * 0.5,
imageColorAllocate($image, 0, 0, 0));
// Draw percentage string
imagefttext($image, 10.0, 0.0,
10 + $boxW + 10,
$height + ($k + 1) * $boxH + $k * $boxH * 0.5 + $boxH / 1.25,
imageColorAllocate($image, 0, 0, 0),
"arial.ttf",
$v . "%");
}
header("Content-Type: image/png");
imagePng($image);
imageDestroy($image);
?>