echo "Query: SELECT DISTINCT host FROM MEASUREMENTS";
}
-$colors = Array("#55F", "#5F5", "#F55", "#5FF", "#F5F", "#FF5", "#555");
+$colors = Array("#55F", "#5C5", "#F55", "#5FF", "#F5F", "#FF5", "#555");
$hosts = Array();
while($host = $result->fetch())
<TITLE>bdsm at monitor.slightlycyberpunk.com | <?php echo $host; ?></TITLE>
</HEAD>
<BODY>
- <canvas class="chart" id="chart-<?php echo $host; ?>" width="400" height="450"></canvas>
+ <canvas class="chart" id="chart-<?php echo $host; ?>" width="400px" height="450px"></canvas>
<script>
var canvas = document.getElementById("chart-<?php echo $host; ?>");
var context = canvas.getContext("2d");
context.strokeStyle = "#CCC";
for (var i = 50; i < 400; i+=50)
{
- context.moveTo(i, 0);
- context.lineTo(i, 400);
+ context.moveTo(i+.5, 0);
+ context.lineTo(i+.5, 400);
}
context.stroke();
context.beginPath();
context.strokeStyle = "#000";
for (var i = 50; i < 400; i+=50)
{
- context.moveTo(0, i);
- context.lineTo(400, i);
+ context.moveTo(0, i+.5);
+ context.lineTo(400, i+.5);
}
context.stroke();
"ORDER BY timestamp DESC LIMIT 100";
$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.font = '12px monospace';";
echo " context.strokeStyle = '$colors[$i]';\n";
+ echo " context.strokeText('-$timestamp', 350.5, ".(10.5+10*$i).");\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.lineTo(".sprintf("%d", $final - $record['timestamp']).", ".(400-$record['value']*4).");\n";
}
echo " context.stroke();\n";
$name = $attributes[$attribute];
- echo " context.strokeText('$name', ".(100*($i%5)).", ".(425+(10*($i/5))).");";
+ echo " context.strokeText('$name', ".(100*($i%5)+.5).", ".(425+(10*floor($i/5))+.5).");";
$i+=1;
}
?>