From: Brian Flowers <git-admn@bsflowers.net> Date: Wed, 16 Nov 2016 02:00:46 +0000 (-0500) Subject: Various cosmetic improvements to the graphs X-Git-Url: http://git.slightlycyberpunk.com%2C%20git.slightlycyberpunk.com/git/?a=commitdiff_plain;h=4f61fcdaa01ebe675b073307f1c36ae6630e6a08;p=bdsm-web.git Various cosmetic improvements to the graphs --- diff --git a/graph.php b/graph.php index 4e72757..42f9ab8 100644 --- a/graph.php +++ b/graph.php @@ -15,7 +15,7 @@ if( !$result ) 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()) @@ -32,7 +32,7 @@ if( !in_array($host, $hosts) ) <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"); @@ -40,8 +40,8 @@ if( !in_array($host, $hosts) ) 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(); @@ -49,8 +49,8 @@ if( !in_array($host, $hosts) ) 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(); @@ -82,30 +82,29 @@ if( !in_array($host, $hosts) ) "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; } ?> diff --git a/index.php b/index.php index c6d2ea2..4354fd8 100755 --- a/index.php +++ b/index.php @@ -16,7 +16,8 @@ try { $db = new PDO("sqlite:/home/bdsm/etc/bdsm/bdsm.db"); - $result = $db->query("SELECT DISTINCT host FROM MEASUREMENTS"); + $result = $db->query("SQLITE_DEFAULT_WAL_AUTOCHECKPOINT=100"); + $result = $db->query("SELECT DISTINCT host FROM MEASUREMENTS"); } catch(PDOException $e) { diff --git a/styles.css b/styles.css index 13e3181..16becd6 100644 --- a/styles.css +++ b/styles.css @@ -36,8 +36,6 @@ { display: inline-block; border: 1px solid black; - width: 400px; - height: 400px; } #options