Code: Select all
and
Code: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi guys,
I use this code to create images from database stats. When i use it on the testing server it works perfectly, but only it doesn't draw the filled rectangle. can anyone help me out on this one.. i've gone mad, looking at this code for hours.
Greets
Daniel
Code: Select all
function create_image($ar_hits,$amount,$name) {
$xax = 550;
$yax = 301;
// Create image
$im = imagecreate($xax,$yax);
// color allocation
$white = imagecolorallocate($im,255,255,255);
$gray = imagecolorallocate($im,200,200,200);
$black = imagecolorallocate($im,0,0,0);
$yellow = imagecolorallocate($im,250,210,119);
// make image white
imagefill($im,0,0,$white);
// Zoek grootste kolom
foreach($ar_hits as $b) {
if($b > $highest) {
$highest = $b;
}
}
if($highest == "") {
$highest = 1;
}
// Stel kolom multiplier in
$deler = 300 / $highest;
$multi = 0.98 * round($deler,3);
// isotopen
for($i=0;$i<=250;$i=$i+50) {
$high = 300 - $i;
$txt_place = $high - 10;
imageline($im,0,$high,$xax,$high,$gray);
$value = floor($i / $multi);
imagestring($im,1,3,$txt_place,$value,$black);
}
// ---------------------------------------------------KOLOM--------------------------------
// Column 1 coordinates
$usable_space = $xax - 21;
$width = floor($usable_space/ $amount);
$start_y = 300;
$start_x = 20;
$start_x2 = $start_x + $width;
// text coordinates
$start_ys = 285;
$start_xs = (($start_x + $start_x2)-6) / 2;
for($i=1;$i<=$amount;$i++) {
// Setting empty columns at zero setting minus ten will make sure nothing is being drawn.
if($ar_hits[$i]=="") {
imagestring($im,2,$start_xs,$start_ys,$i,$black);
$start_xs = $start_xs + $width;
$start_x = $start_x + $width;
$start_x2 = $start_x2 + $width;
}
else {
// Get column Higth.
$hight = 300 - $ar_hits[$i] * $multi;
// draw columns & date
imagefilledrectangle($im,$start_x,$start_y,$start_x2,$hight,$yellow);
imagerectangle($im,$start_x,$start_y,$start_x2,$hight,$black);
imagestring($im,2,$start_xs,$start_ys,$i,$black);
// Update coordinates for next column
$start_xs = $start_xs + $width;
$start_x = $start_x + $width;
$start_x2 = $start_x2 + $width;
}
}
// Axes
imageline($im,0,300,$xax,300,$black);
imageline($im,0,300,0,0,$black);
// Save image
$docname = "./images/";
$docname .= $name;
$docname .= ".jpg";
imagejpeg($im,$docname);
}
feyd | Please use
Code: Select all
and
Code: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]