From 578ba9bbd5a618080a95d5341dc1160e3c41ff18 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 22 Mar 2017 09:49:31 +0000 Subject: [PATCH] Added scientific notation as a unit for #7763 (#7781) --- public/app/core/utils/kbn.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/public/app/core/utils/kbn.js b/public/app/core/utils/kbn.js index f5255b52697..d619d9c4977 100644 --- a/public/app/core/utils/kbn.js +++ b/public/app/core/utils/kbn.js @@ -394,6 +394,10 @@ function($, _) { return "0x" + hexString; }; + kbn.valueFormats.sci = function(value, decimals) { + return value.toExponential(decimals); + }; + // Currencies kbn.valueFormats.currencyUSD = kbn.formatBuilders.currency('$'); kbn.valueFormats.currencyGBP = kbn.formatBuilders.currency('£'); @@ -703,15 +707,16 @@ function($, _) { { text: 'none', submenu: [ - {text: 'none' , value: 'none' }, - {text: 'short', value: 'short' }, - {text: 'percent (0-100)', value: 'percent' }, - {text: 'percent (0.0-1.0)', value: 'percentunit'}, - {text: 'Humidity (%H)', value: 'humidity' }, - {text: 'ppm', value: 'ppm' }, - {text: 'decibel', value: 'dB' }, - {text: 'hexadecimal (0x)', value: 'hex0x' }, - {text: 'hexadecimal', value: 'hex' }, + {text: 'none' , value: 'none' }, + {text: 'short', value: 'short' }, + {text: 'percent (0-100)', value: 'percent' }, + {text: 'percent (0.0-1.0)', value: 'percentunit'}, + {text: 'Humidity (%H)', value: 'humidity' }, + {text: 'ppm', value: 'ppm' }, + {text: 'decibel', value: 'dB' }, + {text: 'hexadecimal (0x)', value: 'hex0x' }, + {text: 'hexadecimal', value: 'hex' }, + {text: 'scientific notation', value: 'sci' }, ] }, {