Click to See Complete Forum and Search --> : can php display bar chart on the webpage??


henri_indon
04-07-2005, 04:49 AM
hi guys,

I have an example:
I retrieve a some data from DB (just call it DBIncome) and i show it on the web pages in a table form.......is there any command in PHP that will allow us to directly print out this details to the printers????

another thing is: instead of a table....can we show it in a bar chart on the webpage???? is there any command for it??? (pie chart also ok).....

DBIncome could be just a simple DB that show Income each year....and i would like to show it on bar chart base on the year....can somebody help me out plzz....

Thanks

scragar
04-07-2005, 05:27 AM
the most common method of drawing a bar chart onto the webpage is use a series of images and vary there height or width to refect the values you want.

<img src="green.gif" height="<? echo $results[0]; ?>" /><br>
<img src="red.gif" height="<? echo $results[1]; ?>" /><br>
<img src="blue.gif" height="<? echo $results[2]; ?>" /><br>

amazing_andr3
04-07-2005, 03:31 PM
How about using CSS instead of images?

http://www.sts.siteuri.ro/index.php?site=islam.siteuri.ro&time=charts&Language=1&Pages=1&Browsers=1&Bots=1&Unknown_UAs=1&Visitor_Referrers=1&Unknown_UA_Referrers=1&Google_Gateway_Pages=1&Google_searches=1&MSN_searches=1&Yahoo_searches=1

OK the fancy CSS graph won't work in IE, but a simple horizontal CSS bar will:

function create_bar($per)
{
echo "<td class='bar'>\n".
"<span style='width:".round($per*2)."px;height:1em;margin:1px 0;float:left;background:rgb(".round(250-$per*2.5).",".round($per*2.5).",".round($per*1.5).");border-top:1px solid black;border-bottom:1px solid black;border-left:1px solid black;'></span>\n".
"<span style='width:".round(200-$per*2)."px;height:1em;margin:1px 0;float:left;background:#DEF;border:1px solid black;'></span>\n".
"</td></tr>\n";
}