Forum Moderators: open

Message Too Old, No Replies

PHP refresh problem

Line graph, new point every 2 seconds

         

dunaken

6:41 pm on Aug 12, 2004 (gmt 0)

10+ Year Member



I have a php routin which will draw a graph from data that I give it. My problems is that new data will b e arriving every two seconds or so. The array will be shifted and the new point added to that last position in the array. This will provide a way of redrawing a line graph using real data, which is continually updated. The browser seems to refuse to update after the first draw.

I am using PHP with the GD extension, which seems fairly straight foward exepts for the update problem.

Anybody got any idea on this, the META REFRESH probably won't work as it will clar the array each time.

Cheers

isitreal

11:56 pm on Aug 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



PHP is server side, once it delivers the item to your page it's done. You'd have to rewrite the routine I think, you could for example put the graph in an iframe, then set the iframe html to metarefresh itself every 2 or 3 seconds, while the overall page would remain static.

I think you'd have to add sessions to make it work the way you want, so there would be a session handler running on the iframe html page that contains the autorefreshing image, that's the only thing I can think of.

dunaken

10:47 am on Aug 13, 2004 (gmt 0)

10+ Year Member



Thanks "isitreal" thats usefull stuff all I require are possible pointers to solutions.

I'll take a look at what an "iframe" does, but I think you are right, I have used the metarefresh for overlaying text on a graphics background and that much works.

I could possibly use a piece of Javascript that goes every so often and grabs a new piece of data, scrolls the array one data piece left and adds the new data piece to the last position. This would provide a way of having a line graph displayed with new data being added. However then i would be mixing my environments and programming languages.

isitreal

2:35 am on Aug 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Javascript will only have access to the data the php provides the page when the server parses it, after that the data js has available can't be updated easily I believe.

I wouldn't mix them, iframes are very easy to use, just make the tiny image page, have that be in the iframe, and have that reload as often as necessary, otherwise the whole page needs to reload, which could lead to very bad results for end users.

dunaken

10:11 am on Aug 14, 2004 (gmt 0)

10+ Year Member



Now you've said it, it makes more sense, thanks for that.

Do you have a snippet of code that contains and iFrame being used, I don't ned much to get going.

I'll also have a look around the internet too see whats available.

Cheers

dunaken

7:43 am on Aug 15, 2004 (gmt 0)

10+ Year Member



Got it done, you came up with just what I neeeded. Found a code snippet with an iframe in it and it worked perfectly.

Many thanks "isitreal"