NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page Graphs with PHP

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
7 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 10-17-2006, 09:59 AM THREAD STARTER               #1 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




Graphs with PHP


This may be simple but it took me a while to figure out, you will need a 1x1 png image for your graph's background

PHP Code:
//Sample Graph
????: NamePros.com http://www.namepros.com/code/248186-graphs-with-php.html
$graph[0] = 5;
????: NamePros.com http://www.namepros.com/showthread.php?t=248186
$graph[1] = 8;
$graph[2] = 1;
$graph[3] = 52;

//How much to scale the graph up (use a decimal to scale down)
$scale 2;

//Code Starts Here
echo '<span style="font-family:\'Courier New\', Courier;">';
    
$i=1;
foreach(
$graph as $point){
     
$point $point $scale;
     if(
$i count($graph)){
          echo 
'<img style="border-top:1px solid #000000;border-left:1px solid #000000;border-bottom:1px solid #000000;" src="graph.png" height="'.$point.'" width="40px"/>';
     }else{
          echo 
'<img style="border:1px solid #000000;" src="graph.png" height="'.$point.'" width="40px"/>';
     }
}
    
echo 
'<br/>';
    
foreach(
$graph as $point){
     if(
$point <= 9){
          echo 
$point.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
     }elseif(
$point <= 99){
          echo 
$day['income'].'&nbsp;&nbsp;&nbsp;&nbsp;';
     }elseif(
$day['income'] <= 999){
          echo 
$day['income'].'&nbsp;&nbsp;&nbsp;';
     }
}
echo 
'</span>'
Barrucadu is offline  
Old 10-17-2006, 10:24 AM   #2 (permalink)
CEO at Syack Inc.
 
-Ray-'s Avatar
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,879
-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of
 




nice little script mate....

THis would make an excellent include for a ipn script im writing....

rep +
__________________
Poker News, articles, discussion
Syack - Shop.. Local

Two great events started with apples. The one that fell on Neuton's head and the one that Steve Jobs bite into.
-Ray- is online now  
Old 10-17-2006, 12:05 PM THREAD STARTER               #3 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




Originally Posted by templaterave
nice little script mate....
????: NamePros.com http://www.namepros.com/showthread.php?t=248186

THis would make an excellent include for a ipn script im writing....

rep +
Thanks, i'm using it to record money i've made/spent at NP.

http://mikor.clearlyhosted.org/dac/graph.png
Barrucadu is offline  
Old 10-17-2006, 12:27 PM   #4 (permalink)
NamePros Member
Join Date: May 2006
Posts: 160
TwistMyArm is on a distinguished road
 



Not to take anything away from you Mikor, but for those who need something a little stronger and don't know about it, there's also the dual-licenced JPGraph library which does all sorts of graphs pretty nicely.
TwistMyArm is offline  
Old 10-17-2006, 12:28 PM THREAD STARTER               #5 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




Originally Posted by TwistMyArm
Not to take anything away from you Mikor, but for those who need something a little stronger and don't know about it, there's also the dual-licenced JPGraph library which does all sorts of graphs pretty nicely.
There is? Damn, i've wasted a few hours, lol
Barrucadu is offline  
Old 10-17-2006, 12:43 PM   #6 (permalink)
NamePros Member
Join Date: May 2006
Posts: 160
TwistMyArm is on a distinguished road
 



So long as you learnt something along the way, you didn't waste any time!

JPGraph is really good: admittedly, it doesn't build the graph straight in to the HTML as yours seems to, but it does do awesome graphs into various file formats. Trust me, it's worth the time to learn!
TwistMyArm is offline  
Closed Thread


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


 
All times are GMT -7. The time now is 03:08 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger