sibga Posted August 14, 2006 Share Posted August 14, 2006 Hello friends..Im again here from ur help .. I made a graph from MySQL data result but need a bit help to look that good and put the X:Y lines in and make as a good graph.Here is the graph i made ... [img]http://svendeprove.vitusflensborg.dk/try/untitled.bmp[/img]Need help in put the X:Y lines and put the tekst on those lines like this http://svendeprove.vitusflensborg.dk/Try/bartableex1.pngHere is the code of Graph i made.<?php header ("Content-type: image/png");ob_start();session_start(); mysql_connect('localhost', 'user', 'user');mysql_select_db('pilot');$result = mysql_query("SELECT * FROM skemaresultat where skr_elev =".$_SESSION['userid']); while ($row= mysql_fetch_assoc($result)) { $values[] = $row["skr_totalpoint"]; }// Get the total number of columns we are going to plot $columns = count($values);// Get the height and width of the final image $width = 400; $height = 300;// Set the amount of space between each column $padding = 10;// Get the width of 1 column $column_width = $width / $columns ;// Generate the image variables $im = imagecreate($width,$height); $gray = imagecolorallocate ($im,0xcc,0xcc,0xcc); $gray_lite = imagecolorallocate ($im,0xee,0xee,0xee); $gray_dark = imagecolorallocate ($im,0x7f,0x7f,0x7f); $white = imagecolorallocate ($im,0xff,0xff,0xff);// Fill in the background of the image imagefilledrectangle($im,0,0,$width,$height,$white); $maxv = 0;// Calculate the maximum value we are going to plot $maxv = max($values);// Now plot each column for($i=0;$i<$columns;$i++) {//echo $values[$i].",".$height.",".$maxv; $column_height = ($height / 100) * (( $values[$i] / $maxv) *100); $x1 = $i*$column_width; $y1 = $height-$column_height; $x2 = (($i+1)*$column_width)-$padding; $y2 = $height;imagefilledrectangle($im,$x1,$y1,$x2,$y2,$gray);// This part is just for 3D effectimageline($im,$x1,$y1,$x1,$y2,$gray_lite);imageline($im,$x1,$y2,$x2,$y2,$gray_lite);imageline($im,$x2,$y1,$x2,$y2,$gray_dark);}// Send the PNG header information. Replace for JPEG or GIF or whatever imagepng($im);?> please help me in that ... Thanks in advance Quote Link to comment Share on other sites More sharing options...
Barand Posted August 14, 2006 Share Posted August 14, 2006 Link to your graph does not display - errors in code Quote Link to comment Share on other sites More sharing options...
sibga Posted August 14, 2006 Author Share Posted August 14, 2006 I have put the picture now ... can u please help me ... i really need that. pleaase help me friends. Quote Link to comment Share on other sites More sharing options...
sibga Posted August 15, 2006 Author Share Posted August 15, 2006 please help me i really need that pleaseee Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 15, 2006 Share Posted August 15, 2006 You really need to learn proper spelling and punctuation. Quote Link to comment Share on other sites More sharing options...
Cook Posted August 15, 2006 Share Posted August 15, 2006 Check out PHPlot.php ([url=http://www.phplot.com]http://www.phplot.com[/url]), a GNU-licensed package to plot all kinds of charts, fairly easy to use, helps you concentrate on conveying your message through good-looking charts rather than spending (wasting?) time on re-inventing the wheel. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.