mirror of https://github.com/dirtbags/moth.git
Working chart output
This commit is contained in:
parent
be2de973ce
commit
f043173cf4
|
@ -1,11 +1,5 @@
|
|||
#! /usr/bin/awk -f
|
||||
|
||||
BEGIN {
|
||||
# Every 2.5 minutes
|
||||
interval = 150
|
||||
tslen = 0
|
||||
}
|
||||
|
||||
function output() {
|
||||
for (t in teams) {
|
||||
score = 0;
|
||||
|
@ -15,14 +9,27 @@ function output() {
|
|||
if (score > maxscore) {
|
||||
maxscore = score
|
||||
}
|
||||
if (score > 0.009) {
|
||||
scores_by_team_time[t, lasttime] = score
|
||||
}
|
||||
}
|
||||
timestamps[tslen++] = lasttime
|
||||
}
|
||||
|
||||
{
|
||||
BEGIN {
|
||||
# High-contrast colors for accessibility
|
||||
colors[0] = "e41a1c"
|
||||
colors[1] = "377eb8"
|
||||
colors[2] = "4daf4a"
|
||||
colors[3] = "984ea3"
|
||||
colors[4] = "ff7f00"
|
||||
colors[5] = "ffff33"
|
||||
colors[6] = "a65628"
|
||||
colors[7] = "f781bf"
|
||||
|
||||
# Every 2.5 minutes
|
||||
interval = 150
|
||||
tslen = 0
|
||||
|
||||
while (1 == getline) {
|
||||
time = $1
|
||||
team = $2
|
||||
cat = $3
|
||||
|
@ -41,16 +48,38 @@ function output() {
|
|||
teams[team] = team
|
||||
points_by_cat[cat] += points
|
||||
points_by_cat_team[cat, team] += points
|
||||
}
|
||||
}
|
||||
|
||||
END {
|
||||
output()
|
||||
|
||||
width = lasttime - start
|
||||
print "<!DOCTYPE html>"
|
||||
print "<html>"
|
||||
print " <head>"
|
||||
print " <title>foo</title>"
|
||||
print " <style type=\"text/css\">"
|
||||
print " body { background: black; }"
|
||||
print " </style>"
|
||||
print " <script type=\"application/javascript\" src=\"file:///home/neale/src/ctf/www/plot.js\"></script>"
|
||||
print " <script type=\"application/javascript\">"
|
||||
print "function draw() {"
|
||||
printf("p = new Plot(\"chart\", %d, %.2f)\n", width, maxscore * 1.1);
|
||||
c = 0
|
||||
for (team in teams) {
|
||||
printf("p.line(\"#%s\",[", colors[c++ % 8])
|
||||
for (i = 1; i < tslen; i += 1) {
|
||||
time = timestamps[i]
|
||||
print time
|
||||
for (team in teams) {
|
||||
printf(" %s: %f\n", team, scores_by_team_time[team, time])
|
||||
printf("[%d,%.2f],",
|
||||
time - start, scores_by_team_time[team, time])
|
||||
}
|
||||
printf("]);\n");
|
||||
}
|
||||
print "}"
|
||||
print "window.onload = draw;"
|
||||
print " </script>"
|
||||
print " </head>"
|
||||
print " <body>"
|
||||
print " <canvas id=\"chart\"></canvas>"
|
||||
print " </body>"
|
||||
print "</html>"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue