dcav-stats/plot.rb

52 lines
1.2 KiB
Ruby
Raw Normal View History

# coding: utf-8
2017-01-24 16:09:09 +00:00
users = ["christoffermadsen","jmaa","jacob","alexander"]
colors = {}
users.each do |user|
colors[user] = "%06x" % (rand * 0xffffff)
end
2017-01-24 16:09:09 +00:00
log_dir = "./log/"
plotstring = %Q[set terminal 'svg' size 800,400
2017-01-24 16:37:27 +00:00
set key bottom outside
set style line 1 lt 1 lw 2 pt 7 ps 0.4
set xlabel "Time"
2017-01-24 16:09:09 +00:00
set xdata time
set timefmt "%s"
set format x "%m/%d"
set xtics 172800
set mxtics 2
set grid ytics mytics xtics mxtics
set title "Screenshot count"
set output "/home/christoffermadsen/public_html/img/screenshot_count.svg"
2017-01-24 16:37:27 +00:00
set ylabel "Count"
set yrange [0:]
2017-01-24 16:37:27 +00:00
set ytics 100
set mytics 2
plot ]
users.each do |user|
plotstring += %Q["log/#{user}.log" using 1:2 with lines ls 1 lc rgb '##{colors[user]}' t "#{user}", \\\n]
end
plotstring += %Q[
set title "Screenshot size"
set output "/home/christoffermadsen/public_html/img/screenshot_size.svg"
set ylabel "Size (MB)"
set yrange [0:100]
set ytics 10
set mytics 1
2017-01-24 16:37:27 +00:00
2017-01-24 16:09:09 +00:00
plot ]
users.each do |user|
2017-01-24 16:37:27 +00:00
colour = "%06x" % (rand * 0xffffff)
plotstring += %Q["log/#{user}.log" using 1:($3/10**6) with lines ls 1 lc rgb '##{colors[user]}' t "#{user}", \\\n]
2017-01-24 16:09:09 +00:00
end
2017-01-24 16:09:09 +00:00
output = File.open("plotscript","w")
output << plotstring
output.close