Explorar el Código

Added UI for time units, minute scalability

utkarshcmu hace 10 años
padre
commit
3c54d14460
Se han modificado 1 ficheros con 23 adiciones y 0 borrados
  1. 23 0
      public/app/core/utils/kbn.js

+ 23 - 0
public/app/core/utils/kbn.js

@@ -489,6 +489,26 @@ function($, _) {
     }
     }
   };
   };
 
 
+  kbn.valueFormats.m = function(size, decimals, scaledDecimals) {
+    if (size === null) { return ""; }
+
+    if (Math.abs(size) < 60) {
+      return kbn.toFixed(size, decimals) + " min";
+    }
+    else if (Math.abs(size) < 1440) {
+      return kbn.toFixedScaled(size / 60, decimals, scaledDecimals, 2, " hour");
+    }
+    else if (Math.abs(size) < 10080) {
+      return kbn.toFixedScaled(size / 1440, decimals, scaledDecimals, 3, " day");
+    }
+    else if (Math.abs(size) < 604800) {
+      return kbn.toFixedScaled(size / 86400, decimals, scaledDecimals, 4, " week");
+    }
+    else {
+      return kbn.toFixedScaled(size / 5.25948e5, decimals, scaledDecimals, 5, " year");
+    }
+  };
+
   ///// FORMAT MENU /////
   ///// FORMAT MENU /////
 
 
   kbn.getUnitFormats = function() {
   kbn.getUnitFormats = function() {
@@ -522,6 +542,9 @@ function($, _) {
           {text: 'microseconds (µs)', value: 'µs'   },
           {text: 'microseconds (µs)', value: 'µs'   },
           {text: 'milliseconds (ms)', value: 'ms'   },
           {text: 'milliseconds (ms)', value: 'ms'   },
           {text: 'seconds (s)',       value: 's'    },
           {text: 'seconds (s)',       value: 's'    },
+          {text: 'minutes (m)',       value: 'm'    },
+          {text: 'hours (h)',         value: 'h'    },
+          {text: 'days (d)',          value: 'd'    },
         ]
         ]
       },
       },
       {
       {