changeset 142:597c40c5719f

Tweak activity plot.
author Daniele Nicolodi <daniele@grinta.net>
date Sun, 16 Oct 2011 23:38:43 +0200
parents 2827664bb785
children 5e847f92a010
files src/ltpdarepo/static/style.css src/ltpdarepo/templates/activity.html src/ltpdarepo/views/browse.py
diffstat 3 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/ltpdarepo/static/style.css	Sun Oct 16 23:38:41 2011 +0200
+++ b/src/ltpdarepo/static/style.css	Sun Oct 16 23:38:43 2011 +0200
@@ -379,6 +379,8 @@
     display: inline-block;
     width: 2em;
     visibility: hidden;
+    font-size: 90%;
+    padding: 2px 0;
 }
 
 .activity td:hover span.num {
--- a/src/ltpdarepo/templates/activity.html	Sun Oct 16 23:38:41 2011 +0200
+++ b/src/ltpdarepo/templates/activity.html	Sun Oct 16 23:38:43 2011 +0200
@@ -14,7 +14,6 @@
 <div class="activity" style="">
   <table>
     <tr>
-      {% set nmax = 300 %}
       {% for day, num in activity %}
       {% set height = num * 300 / nmax %} 
       <td class="bars" style="height: 300px;">
--- a/src/ltpdarepo/views/browse.py	Sun Oct 16 23:38:41 2011 +0200
+++ b/src/ltpdarepo/views/browse.py	Sun Oct 16 23:38:43 2011 +0200
@@ -610,8 +610,14 @@
                         GROUP BY ts.begin, ts.end""" % database)
 
         activity = curs.fetchall()
+        
+        from math import ceil, floor, log10        
+        nmax = max(num for day, num in activity) or 1
+        base = 10**floor(log10(nmax))
+        if base < 10: base = 10.0
+        nmax = ceil(nmax / base)*base
 
-        return render_template('activity.html', database=db, activity=activity,
+        return render_template('activity.html', database=db, activity=activity, nmax=nmax,
                                curr=today, prev=prev, next=next, dt=relativedelta(days=1))