From 218d4812099830b89150e01b61c6c7c8686afdd1 Mon Sep 17 00:00:00 2001 From: Khushil Dep Date: Tue, 25 Feb 2014 13:16:43 +0000 Subject: [PATCH] Add the ability to set microseconds to the Y-Axis on graphs. --- src/app/components/kbn.js | 11 +++++++++++ src/app/directives/grafanaGraph.js | 3 +++ src/app/panels/graphite/axisEditor.html | 4 ++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/app/components/kbn.js b/src/app/components/kbn.js index 3c8f3d30dfa..d74596e4069 100644 --- a/src/app/components/kbn.js +++ b/src/app/components/kbn.js @@ -517,5 +517,16 @@ function($, _, moment) { } }; + kbn.microsFormat = function(size) { + if (size < 1000) { + return size.toFixed(0) + " µs"; + } + else if (size < 1000000) { + return (size / 1000).toFixed(1) + " ms"; + } + else { + return (size / 1000000).toFixed(1) + " s"; + }; + return kbn; }); \ No newline at end of file diff --git a/src/app/directives/grafanaGraph.js b/src/app/directives/grafanaGraph.js index 9e2059b9985..c1d50d5a22a 100644 --- a/src/app/directives/grafanaGraph.js +++ b/src/app/directives/grafanaGraph.js @@ -300,6 +300,9 @@ function (angular, $, kbn, moment, _) { if (format === 'ms') { axis.tickFormatter = kbn.msFormat; } + if (format === 'µs') { + axis.tickFormatter = kbm.microsFormat; + } } function time_format(interval, ticks, min, max) { diff --git a/src/app/panels/graphite/axisEditor.html b/src/app/panels/graphite/axisEditor.html index 2f2f2cb2153..4ce3232411b 100644 --- a/src/app/panels/graphite/axisEditor.html +++ b/src/app/panels/graphite/axisEditor.html @@ -10,11 +10,11 @@
- +
- +