From: Brian Flowers Date: Thu, 10 Nov 2016 03:13:26 +0000 (-0500) Subject: Added timestamps X-Git-Url: http://git.slightlycyberpunk.com%2C%20git.slightlycyberpunk.com/git/?a=commitdiff_plain;h=e4ea98aa21bb73b72df3a5fa1ebf6d464cf9c2ce;p=bdsm-web.git Added timestamps --- diff --git a/graph.php b/graph.php index 0d4e2c9..4e72757 100644 --- a/graph.php +++ b/graph.php @@ -84,9 +84,20 @@ if( !in_array($host, $hosts) ) $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"; @@ -94,7 +105,7 @@ if( !in_array($host, $hosts) ) 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; } ?>