Page 1 of 1
Creating a Line graph.
Posted: Tue Apr 20, 2004 2:16 am
by Simon Angell
Hi.
I am looking to make a line graph using data from an outside file.
In this case its called Temp.log
In Temp.log the data is written like
9.1,2350
9.0,0000
8.6,0010
8.5,0020
8.2,0030
etc etc
With the first being the Temperature, and the second (after the comma) being the time.
How can i get php to get open that file, parse the data and output the relevent Line graph?
Posted: Tue Apr 20, 2004 3:46 am
by CoderGoblin
OK cannot go into too much depth as don't have time so to give you some pointers....
http://de3.php.net/manual/en/ref.filesystem.php
and
http://de3.php.net/manual/en/ref.image.php
Posted: Tue Apr 20, 2004 3:51 am
by JayBird
use these ready made functions. Just feed it the numbers and it does the rest!
Easy!
http://www.panacode.com/panachart/
Mark
Posted: Wed May 12, 2004 10:47 am
by dave420
Bech100 - that's not exactly learning PHP
Using the GD library to generate bar graphs (or pie charts, or anything) is ridiculously easy. Just work out the presentation maths, and you're halfway there. Reading the data from the format you've said is trivial, too.
If you want to learn something, use GD. If you want to get it done sooner, use panachart

Posted: Thu May 13, 2004 12:14 am
by Simon Angell
thanks, had put this little project on the back burner for now, but i would rather learn it, so GD will be my path of choice - if and when i get around to doing it.....
Posted: Thu May 13, 2004 3:12 am
by JayBird
dave420 wrote:Bech100 - that's not exactly learning PHP
I aint here to teach, only to help
Mark
Posted: Thu May 13, 2004 6:49 am
by launchcode
Simon - for a simple line chart you don't even need to mess around with GD, you can just use PHP to write out a table with correctly sized cells (or div tags with widths/heights/etc). Just find the highest and lowest points in your data and base everything around that.
Posted: Thu May 13, 2004 7:41 am
by Simon Angell
Hi.
I decided to look at the pana chart, and am currently sorting thorugh the code - decoding it of sorts. now the data input in the test file is like this
Code: Select all
$vCht4 = array(60,40,20,34,5,52,41,20,34,43,64,40);
$vCht5 = array(12,21,36,27,14,23,3,5,29,23,12,5);
$vCht6 = array(5,7,3,15,7,8,2,2,2,11,22,3);
$vLabels = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
In the example it is the vCht4 data being used..
I wan't the data to be grabbed from an external source (Temp.log)
In Temp.log the data is written like
9.1,2350
9.0,0000
8.6,0010
etc etc and as i stated before the numbers before the , is the plot ($vCht4)
and after is the label $vLables.
How do i get it to read and parse the temp.log file?
(sorry for asking what is a simple question - id rather get this thing working quickly then going through and changing things when i get time as needed etc etc)
Posted: Thu May 13, 2004 11:47 am
by dave420
Bech100 - and we thank you!
