8341: Do not round up Y axis to even numbers, just use max series value.
authorTom Clegg <tom@curoverse.com>
Mon, 8 Feb 2016 20:47:02 +0000 (15:47 -0500)
committerTom Clegg <tom@curoverse.com>
Wed, 10 Feb 2016 16:05:02 +0000 (11:05 -0500)
Remove Y axis labels (so X axis matches other graphs from the same
job), add grid lines.

tools/crunchstat-summary/crunchstat_summary/chartjs.py

index fb30041889c726e4cc14d93a5aaeb7b4e1fbbbd9..03e45e601d39eaa3803f2e75e62c9b6c3721e4f1 100644 (file)
@@ -2,6 +2,7 @@ from __future__ import print_function
 
 import cgi
 import json
+import math
 import pkg_resources
 
 from crunchstat_summary import logger
@@ -35,12 +36,25 @@ class ChartJS(object):
             }
             for s in self.summarizers]
 
+    def _axisY(self, tasks, stat):
+        ymax = 1
+        for task in tasks.itervalues():
+            for pt in task.series[stat]:
+                ymax = max(ymax, pt[1])
+        ytick = math.exp((1+math.floor(math.log(ymax, 2)))*math.log(2))/4
+        return {
+            'gridColor': '#cccccc',
+            'gridThickness': 1,
+            'interval': ytick,
+            'minimum': 0,
+            'maximum': ymax,
+            'valueFormatString': "''",
+        }
+
     def charts(self, label, tasks):
         return [
             {
-                'axisY': {
-                    'minimum': 0,
-                },
+                'axisY': self._axisY(tasks=tasks, stat=stat),
                 'data': [
                     {
                         'type': 'line',