Code: Select all
<?php
header('content-type: image/png');
$url = 'http://chart.apis.google.com/chart?chid=' . md5(uniqid(rand(), true));
$max = '';
$scale = '';
//Crack Height Below
$crack = '50';
if(file_exists('data.csv')){
copy('data.csv', '\current\data.csv');}
$file = fopen('\current\data.csv', 'r');
while (!feof($file) )
{
$line = fgetcsv($file, 40, ',');
$time .= $line[0].'|';
$date = $line[1];
$chd .= $line[2].',';
$scale .= $line[2].'|';
$crackH .= $crack.',';
if ($line[2] > $max)
$max = $line[2];
}
$chd = substr($chd, 0, -1);
$scale = substr($scale, 0, -1);
$time = substr($time, 0, -1);
$crackH = substr($crackH, 0, -1);
// Add data, chart type, chart size, and scale to params.
$chart = array(
'cht' => 'lc',
'chs' => '1000x300',
'chd' => 't:'.$chd.'|'.$crackH,
'chds' => '0,'.$max,
'chco' => '00FF00,FF0000',
'chxt' => 'x,x,y,y,t,r',
'chxl' => '0:|'.$time.'|1:|Time|3:|Levels|4:|'.$time,
'chxr' => '2,0,'.$max.',50|5,0,'.$max.',50',
'chxp' => '1,50|3,50',
'chdl' => 'Levels|Crack Height',
//Client Name Below
'chtt' => 'CLIENT NAME |'.$date,
'chts' => '0000FF,20');
$context = stream_context_create(
array('http' => array(
'method' => 'POST',
'content' => http_build_query($chart))));
fpassthru(fopen($url, 'r', false, $context));
?>