Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Working with graphs in php.
Closed Thread
Old 12-23-2003, 08:24 AM   #1 (permalink)
 
Newb Techie

Join Date: Dec 2003

Posts: 2

Nasimov

Default Working with graphs in php.

Can I do graphs with PHP in Microsoft Windows?

Thanks.
Nasimov is offline  
Old 12-28-2003, 02:30 AM   #2 (permalink)
 
Newb Techie

Join Date: Dec 2003

Posts: 8

XtrEM3

Send a message via AIM to XtrEM3
Thumbs up

Yes,

You can do graphs in PHP. All i kno how to do is bar graphs though.

I dont really know the "official" way of making graphs, but how i would do it is take your values ($varA, $varB), add them together into a variable ($total). Then to get the percents you would do...

$varA_percent = ($varA - $total) *100;
$varB_percent = ($varB - $total) *100;

both of those percents should add up to 100. you can round if u want..

$num_of_decimals = 2;
$varA_percent = round($varA_percent, $num_of_decimals);

now u hav ur percents, you need ur image. U can make a gradient image for your bar if you want, or u can do just plain

now you make a table, you can dress is up w/a grid bg if u want, that seems to work for me. Lets say, for this example, the width is 600 pixels. so you would do...

$varA_width = 600 - $varA_percent;
$varB_width = 600 - $varB_percent;

from that you should b able to print 2 (or however many values you have) bars using ur images that u made.

you can also do like graphs if your server has the ability to create dynamic images on the fly, but i dont have any experience w/dynamic images, so you'll have to get sum1 else to help you in that field.

Tell me if i helped,
Blayne
XtrEM3 is offline  
 
Closed Thread

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On