Forum Moderators: coopster
I've tried Chart 0.7 and jpgraph but they just won't do what I want.
Both the above require a seperate data file to be generated, and then the graph called via an <img src...
Whilst it is good for static data it is of no use for graphing dynamic data from databases.
The problem is that you have to somehow feed the chart.php file with data such as <img src="chart.php?data1=..... However, it is just impossible to pass it an array of any sufficient length.
I've tried urlencode(serialize... and stuff but it's just no good.
Any alternatives out there?
All I'm looking for is to be able to
read a database
display text
display graph
display text
all on one page. You'd think that it would be so easy but due to HTML headers it aint!
so it would be something like:
<p>Show some text</p>
<img src="myimagemaker.php?id=1">
<p>show some more text</p>
JAG
But if you had a chart with hundreds of variables then you'd end up with hundreds of files being written every hour or so.
--
Another way I have heard is to read the database twice.
But say you had a database with a million records. You'd have to scan it twice and it would be slow.
User selects search criteria
Read database and collate
Display table of results
Call chart file
Read database and collate
Display chart
Done
This is the problem. You either have to get the first pass of the database search to save to disk and then get the chart to pick it up, or you have to scan the database twice.
The other way is as I said previously where you serialise the array and pass it via the url. But there is a 2048 or so char limit on passing via url so that I can't pass more than say 30 items of data :(
In the year 2004 I can not believe that it is impossible to read a database, collate data, display that data in a table format, display that data in a graph format all on the same page quickly and efficiently.
I believe it all boils down to the fact that http is rubbish at receiving two streams. i.e. If you have already sent a http header, then you can't then 'print' a graphic element on the same page as it will just display the binary text.
That was probably fine for 1993, but not today!
I guess this is the best way around it?
I've never used them before but it looks easy enough.
start a session
create the array
store the array in the session variable
pass the session_id via the url <img src="chart.php?session_id=...
chart.php reads the array data viar the variable based on the session_id
Does that sound about right?
What about the storing of the session? I notice that sessions can either be stored on disk (yugg!) or in shared memory.
I think it is so archaic to keep storing temporary stuff to disk. How can I ensure that the sessions are all stored in memory?
But if you had a chart with hundreds of variables then you'd end up with hundreds of files being written every hour or so.
Do you mean hundreds of plot points? I'm not sure why you would need hundreds of files unless you were trying to pre make the images for download?
In the year 2004 I can not believe that it is impossible to read a database, collate data, display that data in a table format, display that data in a graph format all on the same page quickly and efficiently.
I suppose you could call an image function as you got the data and write the image to a temp file and then reference the temp image file. Then you could do everything in one pass. You would then just have to make sure you clean them up every so often.
I'm not sure session info would save you all that much if anything. I don't use sessions so I really can't answer that question.
JAG
I'm not sure why you would need hundreds of files unless you were trying to pre make the images for download?
I have a form with dozens and dozens of variables. Currently the form is used to produce tables extracted from the database. A typical user could access this form and produce many tables in the space of a few minutes.
By saving the images to a file (or the data to a file) it wouldn't take long for thousands of files to be generated.
This is what I'm trying to avoid in order to not slow the searches down.
The databases are read only so are mostly running from the cache. If the server then has to keep writing to disk every few seconds multiplied by x users then it's a no go.
I suppose you could call an image function as you got the data and write the image to a temp file
For the very same reason as above. I really want to avoid writing to temp files.
I'm sure sessions vars are the way to go. I just wonder if there is a limit to the size.
e.g. if I have data vars such as:
$ydata1=array(89.1,92.3,94.3 .........);
$ydata2=array(32.7,42.5,29.0 .........);
And I then 'sessionise' them then what is the limit on the size of the array?
In some cases there could be hundreds of plot points.