Jump to content

Display Information Graph


clanstyles

Recommended Posts

I'm just playing w/ some of the numbers right now :P 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 :D Thanks so much again..

Link to comment
Share on other sites

  • Replies 66
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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

Link to comment
Share on other sites

I tried it and it kinda messed it up lol ... It wouldn't write on the map .. :P

 

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 :P

Also, Problem, It seems likes its up side down.. Shouldn't it be flat line at the bottom and go up?

 

:D 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);
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Noo! LoL Don't leave I stillneed help lol its not working **It broke :P**

 

-- 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 :P
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.