diff --git a/bin/plot_bar.sh b/bin/plot_bar.sh index 009e79e..12ffad9 100755 --- a/bin/plot_bar.sh +++ b/bin/plot_bar.sh @@ -5,7 +5,6 @@ # arg 1: path to file with the raw data # arg 2: path to file to save the graph in (.png will be appended) -# arg 3: optional title to show on the graph gnuplot << EOF set datafile separator "," @@ -15,7 +14,6 @@ set boxwidth 0.75 set style fill solid set grid unset key -set title "$3" # If a second arg was supplied we show it as a title too set terminal png size 800,200 transparent truecolor set output "$2.png" diff --git a/bin/plot_time.sh b/bin/plot_time.sh index 56bb882..02441b0 100755 --- a/bin/plot_time.sh +++ b/bin/plot_time.sh @@ -5,7 +5,7 @@ # arg 1: path to file with the raw data # arg 2: path to file to save the graph in (.png will be appended) -# arg 3: optional title to show on the graph +# arg 3: periodic sampling of data, see http://gnuplot.info/docs_4.2/node121.html gnuplot << EOF set datafile separator "," @@ -13,13 +13,10 @@ set xdata time set timefmt "%s" #time format of input data set style data lines -set style line 1 linewidth 2 set grid -set ytics 0, 10 unset key -set title "$3" # If a second arg was supplied we show it as a title too set terminal png size 800,200 transparent truecolor set output "$2.png" -plot "$1" every 4 using 1:2 ls 1 +plot "$1" every $3 using 1:2 linewidth 2 EOF diff --git a/bin/update_graphs.go b/bin/update_graphs.go index 5538578..04da873 100644 --- a/bin/update_graphs.go +++ b/bin/update_graphs.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "path/filepath" + "strconv" "time" _ "github.com/mattn/go-sqlite3" @@ -52,8 +53,9 @@ func main() { for rows.Next() { err := rows.Scan(&id, &title) checkerror(err) - createtimegraph(db, "week-time-", id, title, LAST_WEEK) - createtimegraph(db, "month-time-", id, title, LAST_MONTH) + // stats are updated 4 times per hour, so: 2 = 30 min, 24 = 6 hours + createtimegraph(db, "week-time-", id, title, LAST_WEEK, 4) + createtimegraph(db, "month-time-", id, title, LAST_MONTH, 24) createweekdaygraph(db, "month-avg_day-", id, title, LAST_MONTH) } err = rows.Err() @@ -80,7 +82,7 @@ func setuptemppaths(prefix string, title string) (f *os.File, name string, path return file, file.Name(), path } -func createtimegraph(db *sql.DB, prefix string, id int, title string, period time.Time) { +func createtimegraph(db *sql.DB, prefix string, id int, title string, period time.Time, every int) { ifile, ifilename, ofilename := setuptemppaths(prefix, title) defer ifile.Close() @@ -103,7 +105,7 @@ func createtimegraph(db *sql.DB, prefix string, id int, title string, period tim checkerror(err) // run the plotter against the data file - err = exec.Command("./plot_time.sh", ifilename, ofilename).Run() + err = exec.Command("./plot_time.sh", ifilename, ofilename, strconv.Itoa(every)).Run() checkerror(err) // close and remove the tmp file