$result = $db->query($query);
echo " context.strokeStyle = '$colors[$i]';\n";
$record = $result->fetch();
- $final = $record['timestamp'];
+ $timediff = time() - $final;
+
+ $timestamp = ($timediff % 60)."s";
+ if( $timediff > 60 )
+ $timestamp = (($timediff / 60) % 60)."m ".$timestamp;
+
+
+ echo " context.strokeStyle = '#000000';\n";
+ echo " context.strokeText('-$timestamp', 350, 10);\n";
+
+ echo " context.strokeStyle = '$colors[$i]';\n";
echo " context.moveTo(0, ".sprintf("%d", $record['value']).");\n";
echo " context.beginPath();\n";
+
while( $record = $result->fetch() )
{
echo " context.lineTo(".sprintf("%d", $final - $record['timestamp']).", ".(400-$record['value']*4).");\n";
echo " context.stroke();\n";
$name = $attributes[$attribute];
- echo " context.strokeText('$name', ".(40*$i).", 415);";
+ echo " context.strokeText('$name', ".(100*($i%5)).", ".(425+(10*($i/5))).");";
$i+=1;
}
?>