GnuPlot & Inline Images
| From: | Brian T. Allen | Date: | Sat, 01 Jul 2000 20:43:07 +0000 |
| Subject: | GnuPlot & Inline Images | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-4292@lists.php.net to get a copy of this message | ||
Hi *,
I have this script (below) which uses gnuplot to create graphs on my system.
Everything is working great, but I am having to store the temporary image on
my hard drive, then link to it in the HTML, and go back and delete them
daily.
Is there a way to spit out this image inline, so that it is sent directly to
the browser, instead of stored on the hard drive first?
Thanks,
Brian
====================================
<%
srand((double)microtime()*1000000);
$RAND = rand(100000,999999);
$command = "echo 'set term gif transparent interlace size 600, 400 xFFFFFF
x3366CC
set nokey
set grid
set ytics 500
set xtics 6
set output \"/web/femailcreations/html/images/tmp/$RAND.gif\"
plot \"-\" with lines
";
$query_plot = "SELECT sum(TOTAL) AS hourly_total,DATE_FORMAT(DATE, '%H')
AS new_date FROM ORDER GROUP BY new_date LIMIT 0, 30 ";
$result_plot = mysql_db_query("database", $query_plot);
if ( mysql_num_rows($result_plot) > 0 ){
while ($r = mysql_fetch_array($result_plot)) {
$command .= $r["hourly_total"] . "\n";
}
}
$command .= "\ne' | /usr/bin/gnuplot";
exec($command);
%>
<img src="/images/tmp/<% echo $RAND %>.gif" border="0">
=======================================