<?php //fill in chart parameters $ChartDiameter = 300; $ChartFont = 5; $ChartFontHeight = imagefontheight($ChartFont); "Beef"=>"99", "Pork"=>"75", "Chicken"=>"15", "Lamb"=>"66", "Fish"=>"22"); //determine graphic size $ChartWidth = $ChartDiameter + 20; $ChartHeight = $ChartDiameter + 20 + //determine total of all values //set center of pie $ChartCenterX = $ChartDiameter/2 + 10; $ChartCenterY = $ChartDiameter/2 + 10; //create image $image = imagecreate($ChartWidth, $ChartHeight); imageantialias($image, TRUE); //create a round brush for drawing borders $dot = imagecreate(10, 10); $dotColorBlack = imagecolorallocate($dot, 0, 0, 0); $dotColorTransparent = imagecolorallocate($dot, 255, 0, 255); imagecolortransparent($dot, $dotColorTransparent); imagefill($dot, 0, 0, $dotColorTransparent); imagefilledellipse($dot, 4, 4, 5, 5, $dotColorBlack); imagesetbrush($image, $dot); //allocate colors $colorBody = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); $colorBorder = imagecolorallocate($image, 0x00, 0x00, 0x00); $colorText = imagecolorallocate($image, 0x00, 0x00, 0x00); imagecolorallocate($image, 0xFF, 0x00, 0x00), imagecolorallocate($image, 0x00, 0xFF, 0x00), imagecolorallocate($image, 0x00, 0x00, 0xFF), imagecolorallocate($image, 0xFF, 0xFF, 0x00), imagecolorallocate($image, 0xFF, 0x00, 0xFF), imagecolorallocate($image, 0x00, 0xFF, 0xFF), imagecolorallocate($image, 0x99, 0x00, 0x00), imagecolorallocate($image, 0x00, 0x99, 0x00), imagecolorallocate($image, 0x00, 0x00, 0x99), imagecolorallocate($image, 0x99, 0x99, 0x00), imagecolorallocate($image, 0x99, 0x00, 0x99), imagecolorallocate($image, 0x00, 0x99, 0x99)); //fill background imagefill($image, 0, 0, $colorBody); /* ** draw each slice */ $Degrees = 0; $slice=0; foreach($ChartData as $label=>$value) { $Degrees += (($value/$ChartTotal)*360); //draw pie slice imagefilledarc( $image, $ChartCenterX, $ChartCenterY, $ChartDiameter,$ChartDiameter, $StartDegrees, $EndDegrees, $CurrentColor, IMG_ARC_PIE); //draw legend for this slice $LineY = $ChartDiameter + 20 + ($slice*($ChartFontHeight+2)); imagerectangle($image, 10, $LineY, 10 + $ChartFontHeight, $LineY+$ChartFontHeight, $colorBorder); imagefilltoborder($image, 12, $LineY + 2, $colorBorder, $CurrentColor); imagestring($image, $ChartFont, 20 + $ChartFontHeight, $LineY, "$label: $value", $colorText); $slice++; } //draw border imageellipse($image, $ChartCenterX, $ChartCenterY, $ChartDiameter,$ChartDiameter, IMG_COLOR_BRUSHED); //output image imagepng($image); ?>
Chcialem sobie go wykorzystac lecz niestety nie wyswietla mi tego obrazka. Jest tylko taki znaczek jak przegladarka nie moze znalesc obrazka. Zmienilem
header("Content-type: image/png"); na header("Content-type: image/gif"); i
imagepng($image); na imagegif($image);
bo mam wersje gd 2.0.28 a w tej wersji nie wyswietla chyba png. Zreszta przy png wyswietalo mi blad "obrazek nie moze byc wyswietlony bo zawieral bledy"
Przyznaje odrazu ze nie mam pojecia o gd poprostu chcialem skorzystac z gotowego przykladu.
Ma ktos jakis pomysl?