clanstyles Posted June 28, 2007 Author Share Posted June 28, 2007 I'm just playing w/ some of the numbers right now its kinda hard. I need it more like maticulis on how it shows it because later I am going to have it put like Ranges in there: 2TB 1TB 500G and probally l ike 1.5TB 1TB 750G 500G ect.. So yeah Thanks so much again.. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 28, 2007 Share Posted June 28, 2007 did you try my add on? also did you rescale it up to 500x500 you have such a big span (10k range) that you need a bigger plot to get a better graph Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 28, 2007 Share Posted June 28, 2007 fyi change colors to: $colorWhite=imagecolorallocate($image, 0, 0, 0); if($srvcount == "1"){$color =imagecolorallocate($image, 45, 87, 192);} else{$color = imagecolorallocate($image, 0, 255, 255);} way way way easier to read also incase you want to add on more colors for more lines change the else to an elseif and apend it with more numbers Quote Link to comment Share on other sites More sharing options...
clanstyles Posted June 28, 2007 Author Share Posted June 28, 2007 I tried it and it kinda messed it up lol ... It wouldn't write on the map .. so Nope :- ( Edit: Yeah Got it http://gungame.cswiki.org/technicolor/graph.php Edit: Yeah I have been making it red or blue but you change it back w/ ur updates Also, Problem, It seems likes its up side down.. Shouldn't it be flat line at the bottom and go up? thanks My Updated: <?php include("config.php"); // Define .PNG image header("Content-type: image/png"); $imgWidth=500; $imgHeight=500; $result = mysql_query("SELECT size,timestamp,serverid FROM `serverInfo`") or die(mysql_error()); while( $row= mysql_fetch_array($result)){ $temptime = str_replace(", ","",$row['timestamp']); $sizes[$temptime][] = $row['size']; $graphValues[$row['serverid']][] = $row['size']; } // Create image and define colors $image=imagecreate($imgWidth, $imgHeight) or die ("GD ERROR"); $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, 500, $colorGrey); imageline($image, 0, 0, 500, 0, $colorGrey); imageline($image, 499, 0, 499, 499, $colorGrey); imageline($image, 0, 499, 499, 499, $colorGrey); //imagefttext($image, 12.0, 12.0, 0, 0, 0, "", "12"); // Create grid for ($i=1; $i<365; $i++){ imageline($image, $i*10, 0, $i*10, 500, $colorGrey); imageline($image, 0, $i*10, 500, $i*10, $colorGrey); } $srvcount = 1; $numservers = 1; while ($srvcount <=$numservers) { arsort($graphValues[$srvcount]); $maxsize = current($graphValues[$srvcount]); $scale = $maxsize/250; if($srvcount == "1"){$color =imagecolorallocate($image, 255, 0, 0);} else{$color = imagecolorallocate($image, 0, 0, 255);} $j = 0; $x[0] = 0; $y[0] = 0; $numpoints = count($graphValues[$srvcount])-1; while ($j < $numpoints) { $k = $j+1; $x[$j] = $x[$j]; $x[$k] = $x[$j]+50; $y[$j] = round($graphValues[$srvcount][$j]/$scale); $y[$k] = round($graphValues[$srvcount][$k]/$scale); imageline($image, $x[$j], $y[$j], $x[$k], $y[$k], $color); $j++; } $srvcount++; } // Output graph and clear image from memory imagepng($image); imagedestroy($image); ?> Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 28, 2007 Share Posted June 28, 2007 the derrivation of the line is depdent on each point, however somehow its still over peaking your graph's range change the dividing factor on the scale from 250 to 500 and it should work Quote Link to comment Share on other sites More sharing options...
clanstyles Posted June 28, 2007 Author Share Posted June 28, 2007 I just put it out of 100 and it looks fine. How do I set it to the bottom and going up? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 28, 2007 Share Posted June 28, 2007 can you show me the data for the sizes I think you are misunderstanding your output. But it can be flipped if you say $y[$j] = 500-round($graphValues[$srvcount][$j]/$scale); $y[$k] = 500-round($graphValues[$srvcount][$k]/$scale); That will invert each point (i.e the point 0,400 becomes 0,100 on a 500 high graph Quote Link to comment Share on other sites More sharing options...
clanstyles Posted June 28, 2007 Author Share Posted June 28, 2007 Ahh Check it out w00t loL Nice Thx u so much I think this is it! I might need help later but now im giong to add some text along the sides... Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 28, 2007 Share Posted June 28, 2007 yeah read up on the GD img stuff, but your X axis isn't truely scaled, the Y can be scaled with a bit of Math Using that scale factor but yeah that should do it for you I'm off cya Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 28, 2007 Share Posted June 28, 2007 fyi either your data points are extremly low/high or you don't have the scaler set right cause it seems like a lot of data is 0ing out Quote Link to comment Share on other sites More sharing options...
clanstyles Posted June 28, 2007 Author Share Posted June 28, 2007 Noo! LoL Don't leave I stillneed help lol its not working **It broke ** -- phpMyAdmin SQL Dump -- version 2.8.2.4 -- http://www.phpmyadmin.net -- -- Host: technicolor.cswiki.org -- Generation Time: Jun 28, 2007 at 04:37 PM -- Server version: 5.0.24 -- PHP Version: 4.4.7 -- -- Database: `technicolor` -- -- -------------------------------------------------------- -- -- Table structure for table `serverInfo` -- CREATE TABLE `serverInfo` ( `id` int(11) NOT NULL auto_increment, `serverid` int(11) NOT NULL, `size` int(11) NOT NULL, `filename` text NOT NULL, `timestamp` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=222 DEFAULT CHARSET=latin1; -- -- Dumping data for table `serverInfo` -- INSERT INTO `serverInfo` (`id`, `serverid`, `size`, `filename`, `timestamp`) VALUES (221, 1, 4, 'work.txt', '06/21/07'), (220, 1, 4, 'whatismyip', '06/21/07'), (219, 1, 52, 'test', '06/21/07'), (218, 1, 60500, 'technicolor', '06/21/07'), (217, 1, 4, 'ssh.php', '06/21/07'), (216, 1, 4, 'search.php', '06/21/07'), (215, 1, 656, 'raiderboy', '06/21/07'), (214, 1, 4, 'musicinfo.xml', '06/21/07'), (213, 1, 49560, 'music', '06/21/07'), (212, 1, 1300, 'layout.bmp', '06/21/07'), (211, 1, 284, 'java', '06/21/07'), (210, 1, 4, 'index.php', '06/21/07'), (209, 1, 8, 'hl.class.php', '06/21/07'), (208, 1, 4, 'header.php', '06/21/07'), (207, 1, 116, 'gungame.sql', '06/21/07'), (206, 1, 4, 'glider.php', '06/21/07'), (205, 1, 4, 'footer.php', '06/21/07'), (204, 1, 4, 'config.php', '06/21/07'), (203, 1, 12, 'carmod.rar', '06/21/07'), (202, 1, 12, 'blackmarket', '06/21/07'), (201, 1, 4, 'ReadMe.txt', '06/21/07'), (200, 1, 4, 'Jumba.rar', '06/21/07'), (199, 1, 4, 'Gungame.rar', '06/21/07'), (198, 1, 12, 'BrentAIM.txt', '06/21/07'), (197, 1, 8, 'Brent.txt', '06/21/07'), (196, 1, 112, 'BMMods.rar', '06/21/07'), (195, 1, 4, 'testdata.php', '06/21/07'), (194, 1, 4, 'ssh.php', '06/21/07'), (193, 1, 4, 'main.php', '06/21/07'), (192, 1, 4, 'login.php', '06/21/07'), (191, 1, 4, 'index.php', '06/21/07'), (190, 1, 4, 'header.php', '06/21/07'), (189, 1, 4, 'graph.php', '06/21/07'), (188, 1, 4, 'footer.php', '06/21/07'), (187, 1, 4, 'data.php', '06/21/07'), (186, 1, 4, 'config.php', '06/21/07'), (185, 1, 60460, 'Data', '06/21/07'); I have all this data in there and it is coming out all weird. It isan't coming out like it would over a 12 month period and it also isan't Fluxing enough i don't think Quote Link to comment Share on other sites More sharing options...
Barand Posted June 29, 2007 Share Posted June 29, 2007 Two things to say about your data 1 ) Dates held in that format are totally useless in a database - you can't - sort on it, - select ranges, - compare dates, - use date/time functions 2 ) text type fields are for storing large amounts of text (like a small novel) Use column type DATE and store in yyyy-mm-dd format for maximum functionality. And if you want an average of size for each date, let SQL do the work SELECT timestamp, AVG(size) as avsize FROM serverInfo GROUP BY timestamp Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 29, 2007 Share Posted June 29, 2007 I'm back, but your main issue is your data doesn't even merit graphical analysis in that fashion, your are comparing different files (var 1) at different times (var 2) at different sizes (var 3) all which would lead you to a more 3 demenionsal analysis on a x,y,z plane not a x,y plane as we are doing right now. That or do a x,y with multiple lines Quote Link to comment Share on other sites More sharing options...
clanstyles Posted June 29, 2007 Author Share Posted June 29, 2007 tomorrow ill do that update the date and the text type. Thanks And as for the graph I don't get it cloud. I just want somthing Alexa.com It doesn't seem to come out like that if you et what i mean. THank YOU!! Quote Link to comment Share on other sites More sharing options...
clanstyles Posted June 29, 2007 Author Share Posted June 29, 2007 I'm playing around with this and its not working mod $result = mysql_query("SELECT filename FROM serverInfo GROUP BY timestamp"); $a=0; while($res = mysql_fetch_array($result)) { imagefttext($image, 26.0, 35+10, 35, 450, 2, $fontfile, $res[0]); $a++; } It only prints out ONE.. there are like 15 entrys Quote Link to comment Share on other sites More sharing options...
Barand Posted June 29, 2007 Share Posted June 29, 2007 You have to use aggregation functions such as SUM(), COUNT(), AVG(), MIN(), MAX() with the GROUP BY clause. IF you select fields other than the field/s you are grouping by, their content will come from ONE record only in that group (usually the first record) The code I gave returns each date and the av size for each date. BTW, are dates supposed to be the same in every record as in your dump? Quote Link to comment Share on other sites More sharing options...
clanstyles Posted June 29, 2007 Author Share Posted June 29, 2007 Well how this is supposed to work is I have a script I made that runs once a day on a server at its lowest time of activity like midnight. It goes in with ssh2 and runs a command and grabs all the folders and bytes sizes ( in bytes ). The date for that is going to be what ever the date is, that it was run on. So if its run today ( June 29, 2007 ) the date will be June 29, 2007. Now what I need to do is show this data on a graph and average out the data. Then they can click on the server and see individual how the directory's changed over time. 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.