[ARVADOS] created: 1.1.0-96-g805b4e7

Git user git at public.curoverse.com
Thu Nov 2 14:01:53 EDT 2017


        at  805b4e7f801853e69514b11942bc2e5f79bc9dbd (commit)


commit 805b4e7f801853e69514b11942bc2e5f79bc9dbd
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date:   Thu Nov 2 13:59:42 2017 -0400

    12478: Fix time-offset formatting + use more natural tick intervals.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>

diff --git a/tools/crunchstat-summary/crunchstat_summary/dygraphs.js b/tools/crunchstat-summary/crunchstat_summary/dygraphs.js
index 6a6225d..5c1d099 100644
--- a/tools/crunchstat-summary/crunchstat_summary/dygraphs.js
+++ b/tools/crunchstat-summary/crunchstat_summary/dygraphs.js
@@ -13,16 +13,30 @@ window.onload = function() {
             return y.toFixed(2).replace(/\.0+$/, '')+s;
         },
         time: function(s) {
-            var u='s';
-            if (s < 60) return s;
-            var u = 'm'+(s%60)+'s';
-            var m = Math.floor(s/60);
-            if (m < 60) return ''+m+u;
-            u = 'h'+(m%60)+u;
-            var h = Math.floor(m/60);
-            if (h < 24) return ''+h+u;
-            u = 'd'+(h%24)+s;
-            return ''+Math.floor(h/24)+u;
+            var ret = ''
+            if (s >= 86400) ret += Math.floor(s/86400) + 'd'
+            if (s >= 3600) ret += Math.floor(s/3600)%24 + 'h'
+            if (s >= 60) ret += Math.floor(s/60)%60 + 'm'
+            ret += Math.floor(s)%60 + 's'
+            // finally, strip trailing zeroes: 1d0m0s -> 1d
+            return ret.replace(/(\D)(0\D)*$/, '$1')
+        },
+    }
+    var ticker = {
+        time: function(min, max, pixels, opts, dg) {
+            var max_ticks = Math.floor(pixels / opts('pixelsPerLabel'))
+            var natural = [1, 5, 10, 30, 60,
+                           120, 300, 600, 1800, 3600,
+                           7200, 14400, 43200, 86400]
+            var interval = natural.shift()
+            while (max>min && (max-min)/interval > max_ticks) {
+                interval = natural.shift() || (interval * 2)
+            }
+            var ticks = []
+            for (var i=Math.ceil(min/interval)*interval; i<=max; i+=interval) {
+                ticks.push({v: i, label: fmt.time(i)})
+            }
+            return ticks
         },
     }
     chartdata.forEach(function(section, section_idx) {
@@ -47,6 +61,7 @@ window.onload = function() {
                 x: {
                     axisLabelFormatter: fmt.time,
                     valueFormatter: fmt.time,
+                    ticker: ticker.time,
                 },
                 y: {
                     axisLabelFormatter: fmt.iso,

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list