• You are not logged in. | Login

Post a reply

  • Index
  •  » Help me!
  •  » How to build a time dependence graphic from one-dimensional numbers

January 16, 2007 11:07 am

mdwb
Member
Ranks

How to build a time dependence graphic from one-dimensional numbers

: Help me please with such a question: there is a one-dimensional numbers array. How to build a time dependence graphic from these numbers if you know that each following number should be equidistant from the previous one relatively to the time scale (X)? And relatively to the scale Y it depends on the meaning of the number itself.
Give a brief example if possible.


Don't be afraid of life, it is yours!

 

 

January 16, 2007 11:14 am

bobbee
Member
Ranks

Re: How to build a time dependence graphic from one-dimensional numbers

$data = array(1, 2, 3, 4, 3, 2, 1);
$im = imagecreate(count($data), 7);
$background = imagecolorallocate($im, 255, 255, 255);
$color = imagecolorallocate($im, 0, 0, 0);
for($i=0; $i<count($data); $i++){
   imagesetpixel($im, $i, $data[$i], $color);
}
imagepng($im);
imagedestroy($im);

 

 

January 16, 2007 11:14 am

mdwb
Member
Ranks

Re: How to build a time dependence graphic from one-dimensional numbers

I’ve recorded and saved it but it writes "‰PNG  " when starting. What could it mean?


Don't be afraid of life, it is yours!

 

 

January 16, 2007 11:16 am

phppat
Member
Ranks

Re: How to build a time dependence graphic from one-dimensional numbers

Invalid title is indicated on the page and namely mime-type!


PHP monster

 

 

January 16, 2007 11:19 am

reetesh
Member
Ranks

Re: How to build a time dependence graphic from one-dimensional numbers

add following string into the code before imagepng($im);
      header("Content-type: image/png");

Last edited by reetesh (January 16, 2007 11:20 am)


 

 

January 16, 2007 11:21 am

mdwb
Member
Ranks

Re: How to build a time dependence graphic from one-dimensional numbers

<?php
$data = array(1, 2, 3, 4, 3, 2, 1);
$im = imagecreate(count($data), 7);
$background = imagecolorallocate($im, 255, 255, 255);
$color = imagecolorallocate($im, 0, 0, 0);
for($i=0; $i<count($data); $i++){
imagesetpixel($im, $i, $data[$i], $color);
}
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
?>

I’ve typed like this. I start "localhost/****.php" in the browser. First it is starting very long time and then nothing! Blank browser ‘blank page’.

Can someone prove himself if it functions or not?

And here is another thing! In the editor operator imagepng($im) isn’t indicated in bold like the rest – something may be disconnected. Give me a tip what should be switched on.

I’ve forgotten to switch on Apache before starting. But it isn’t working anyway. It has written following stuff:

Warning: Cannot modify header information - headers already sent by (output started at z:\home\localhost\www\graph.php:8) in z:\home\localhost\www\graph.php on line 16
‰PNG   IHDRjuЕђPLTEzzzUВУ~IDATxjc``hbpaР` ` piUf…\IEND®B`‚

What should I do?
Line 16 is a header


Don't be afraid of life, it is yours!

 

 

January 16, 2007 11:22 am

mdwb
Member
Ranks

Re: How to build a time dependence graphic from one-dimensional numbers

It works! Thanks for everybody!!!
But it functions on the server not at home…. What should I install and how?


Don't be afraid of life, it is yours!

 

 

January 16, 2007 11:24 am

bobbee
Member
Ranks

Re: How to build a time dependence graphic from one-dimensional numbers

At least you are to switch on GD. And you are to check against blank strings at home. It will be a good manner to write mime-type as the first line after &lt;?php


 

 

January 16, 2007 11:24 am

mdwb
Member
Ranks

Re: How to build a time dependence graphic from one-dimensional numbers

How should I switch on GD? And what is mime? How to write it? Where cat I get GD? And how to install it?
     Can you answer all these questions?


Don't be afraid of life, it is yours!

 

 

January 16, 2007 11:26 am

reetesh
Member
Ranks

Re: How to build a time dependence graphic from one-dimensional numbers

do you use denver? If so delete it immediately and install XAMPP ( http://apachefriends.com/ )


 

 

January 16, 2007 11:26 am

mdwb
Member
Ranks

Re: How to build a time dependence graphic from one-dimensional numbers

Sure, I use it. And if I delete denver it also breaks the bases created by it, won’t they?
     Is XAMPP really better? And what is it?


Don't be afraid of life, it is yours!

 

 

January 16, 2007 11:27 am

mellis
Member
Ranks

Re: How to build a time dependence graphic from one-dimensional numbers

I advise you to pay attention to [ JPGRAPH ] for working with graphics.


 

 

January 16, 2007 11:28 am

Re: How to build a time dependence graphic from one-dimensional numbers

Learn three words Apache, PHP, Mishcool. Forget about XAMPP.


 

 
  • Index
  •  » Help me!
  •  » How to build a time dependence graphic from one-dimensional numbers
  • Actions
  • Top
ITCrimea. Ukraine Web Development Company. Professional Developers and Web Designers Team
Custom Web Designs, Internet Applications, E-Commerce Websites, Interactive Sites, Database-Driven Sites and Services