Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 22-08-06
Northern Monkey's Avatar
Member
 
Join Date: Jan 2004
Location: UK
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Northern Monkey is an unknown quantity at this point
  More Statistics Graphs....

Ok,

I have the following code for creatnig a bar chart (called grid.php). I call it in my program using <img src="grid.php">. The only problem is I want to pass an array of variables to it (graphValues) but am having trouble. If I call it as a function it doesn't like the header("Content-type: image/png"); line as they have already been defined. Any idea? Code is below for reference.

Cheers,

NM.



<?
// Add values to the graph
$graphValues=array(0,80,23,11,190,245,50,80,111,24 0,55);

// Define .PNG image
header("Content-type: image/png");
$imgWidth=250;
$imgHeight=250;

// Create image and define colors
$image=imagecreate($imgWidth, $imgHeight);
$colorWhite=imagecolorallocate($image, 255, 255, 255);
$colorGrey=imagecolorallocate($image, 192, 192, 192);
$colorBlue=imagecolorallocate($image, 0, 0, 255);

// Create border around image
imageline($image, 0, 0, 0, 250, $colorGrey);
imageline($image, 0, 0, 250, 0, $colorGrey);
imageline($image, 249, 0, 249, 249, $colorGrey);
imageline($image, 0, 249, 249, 249, $colorGrey);

// Create grid
for ($i=1; $i<11; $i++){
imageline($image, $i*25, 0, $i*25, 250, $colorGrey);
imageline($image, 0, $i*25, 250, $i*25, $colorGrey);
}

// Create line graph
for ($i=0; $i<10; $i++){
imageline($image, $i*25, (250-$graphValues[$i]), ($i+1)*25, (250 - $graphValues[$i+1]), $colorBlue);
}

// Output graph and clear image from memory
imagepng($image);
imagedestroy($image);
?>
__________________
Holiday Villa In<br>
<font size=2>If it moves, kick it. If it doesn't move, kick it till it moves and hen kick it because it moved</font>

Last edited by Northern Monkey; 23-08-06 at 08:08 AM..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 23-08-06
Northern Monkey's Avatar
Member
 
Join Date: Jan 2004
Location: UK
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Northern Monkey is an unknown quantity at this point
Must say this is a first, not a peep from anyone :eek: I'll do a bit more digging....
__________________
Holiday Villa In<br>
<font size=2>If it moves, kick it. If it doesn't move, kick it till it moves and hen kick it because it moved</font>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 23-08-06
Registered User
 
Join Date: Dec 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Tony Harrison is an unknown quantity at this point
Don't really know about your problem but instead of using the image functions directly I would use one of the many graphing libraries out there. Only one I've used is PEAR's Image_Graph http://pear.php.net/package/Image_Graph

No point re-inventing the wheel!
__________________
Hair Supermarket - 10% on Webgains. tony @ sekl.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Statistics Delay - Approximately 20 hours TD Nick TradeDoubler 5 16-11-05 02:22 PM
Statistics Issue Update and Cause TD Nick TradeDoubler 22 27-08-05 08:33 PM
Statistics Delay - Scheduled Maintenance 27th - 28th TD Nick TradeDoubler 11 27-05-05 08:37 PM
TradeDoubler Statistics Disturbance TD Nick TradeDoubler 16 14-10-03 04:21 PM


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7