kbn.ts 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  1. import _ from 'lodash';
  2. import moment from 'moment';
  3. var kbn: any = {};
  4. kbn.valueFormats = {};
  5. kbn.regexEscape = function(value) {
  6. return value.replace(/[\\^$*+?.()|[\]{}\/]/g, '\\$&');
  7. };
  8. ///// HELPER FUNCTIONS /////
  9. kbn.round_interval = function(interval) {
  10. switch (true) {
  11. // 0.015s
  12. case interval < 15:
  13. return 10; // 0.01s
  14. // 0.035s
  15. case interval < 35:
  16. return 20; // 0.02s
  17. // 0.075s
  18. case interval < 75:
  19. return 50; // 0.05s
  20. // 0.15s
  21. case interval < 150:
  22. return 100; // 0.1s
  23. // 0.35s
  24. case interval < 350:
  25. return 200; // 0.2s
  26. // 0.75s
  27. case interval < 750:
  28. return 500; // 0.5s
  29. // 1.5s
  30. case interval < 1500:
  31. return 1000; // 1s
  32. // 3.5s
  33. case interval < 3500:
  34. return 2000; // 2s
  35. // 7.5s
  36. case interval < 7500:
  37. return 5000; // 5s
  38. // 12.5s
  39. case interval < 12500:
  40. return 10000; // 10s
  41. // 17.5s
  42. case interval < 17500:
  43. return 15000; // 15s
  44. // 25s
  45. case interval < 25000:
  46. return 20000; // 20s
  47. // 45s
  48. case interval < 45000:
  49. return 30000; // 30s
  50. // 1.5m
  51. case interval < 90000:
  52. return 60000; // 1m
  53. // 3.5m
  54. case interval < 210000:
  55. return 120000; // 2m
  56. // 7.5m
  57. case interval < 450000:
  58. return 300000; // 5m
  59. // 12.5m
  60. case interval < 750000:
  61. return 600000; // 10m
  62. // 12.5m
  63. case interval < 1050000:
  64. return 900000; // 15m
  65. // 25m
  66. case interval < 1500000:
  67. return 1200000; // 20m
  68. // 45m
  69. case interval < 2700000:
  70. return 1800000; // 30m
  71. // 1.5h
  72. case interval < 5400000:
  73. return 3600000; // 1h
  74. // 2.5h
  75. case interval < 9000000:
  76. return 7200000; // 2h
  77. // 4.5h
  78. case interval < 16200000:
  79. return 10800000; // 3h
  80. // 9h
  81. case interval < 32400000:
  82. return 21600000; // 6h
  83. // 1d
  84. case interval < 86400000:
  85. return 43200000; // 12h
  86. // 1w
  87. case interval < 604800000:
  88. return 86400000; // 1d
  89. // 3w
  90. case interval < 1814400000:
  91. return 604800000; // 1w
  92. // 6w
  93. case interval < 3628800000:
  94. return 2592000000; // 30d
  95. default:
  96. return 31536000000; // 1y
  97. }
  98. };
  99. kbn.secondsToHms = function(seconds) {
  100. var numyears = Math.floor(seconds / 31536000);
  101. if (numyears) {
  102. return numyears + 'y';
  103. }
  104. var numdays = Math.floor((seconds % 31536000) / 86400);
  105. if (numdays) {
  106. return numdays + 'd';
  107. }
  108. var numhours = Math.floor(((seconds % 31536000) % 86400) / 3600);
  109. if (numhours) {
  110. return numhours + 'h';
  111. }
  112. var numminutes = Math.floor((((seconds % 31536000) % 86400) % 3600) / 60);
  113. if (numminutes) {
  114. return numminutes + 'm';
  115. }
  116. var numseconds = Math.floor((((seconds % 31536000) % 86400) % 3600) % 60);
  117. if (numseconds) {
  118. return numseconds + 's';
  119. }
  120. var nummilliseconds = Math.floor(seconds * 1000.0);
  121. if (nummilliseconds) {
  122. return nummilliseconds + 'ms';
  123. }
  124. return 'less than a millisecond'; //'just now' //or other string you like;
  125. };
  126. kbn.to_percent = function(nr, outof) {
  127. return Math.floor(nr / outof * 10000) / 100 + '%';
  128. };
  129. kbn.addslashes = function(str) {
  130. str = str.replace(/\\/g, '\\\\');
  131. str = str.replace(/\'/g, "\\'");
  132. str = str.replace(/\"/g, '\\"');
  133. str = str.replace(/\0/g, '\\0');
  134. return str;
  135. };
  136. kbn.interval_regex = /(\d+(?:\.\d+)?)(ms|[Mwdhmsy])/;
  137. // histogram & trends
  138. kbn.intervals_in_seconds = {
  139. y: 31536000,
  140. M: 2592000,
  141. w: 604800,
  142. d: 86400,
  143. h: 3600,
  144. m: 60,
  145. s: 1,
  146. ms: 0.001,
  147. };
  148. kbn.calculateInterval = function(range, resolution, lowLimitInterval) {
  149. var lowLimitMs = 1; // 1 millisecond default low limit
  150. var intervalMs;
  151. if (lowLimitInterval) {
  152. if (lowLimitInterval[0] === '>') {
  153. lowLimitInterval = lowLimitInterval.slice(1);
  154. }
  155. lowLimitMs = kbn.interval_to_ms(lowLimitInterval);
  156. }
  157. intervalMs = kbn.round_interval((range.to.valueOf() - range.from.valueOf()) / resolution);
  158. if (lowLimitMs > intervalMs) {
  159. intervalMs = lowLimitMs;
  160. }
  161. return {
  162. intervalMs: intervalMs,
  163. interval: kbn.secondsToHms(intervalMs / 1000),
  164. };
  165. };
  166. kbn.describe_interval = function(str) {
  167. var matches = str.match(kbn.interval_regex);
  168. if (!matches || !_.has(kbn.intervals_in_seconds, matches[2])) {
  169. throw new Error('Invalid interval string, expecting a number followed by one of "Mwdhmsy"');
  170. } else {
  171. return {
  172. sec: kbn.intervals_in_seconds[matches[2]],
  173. type: matches[2],
  174. count: parseInt(matches[1], 10),
  175. };
  176. }
  177. };
  178. kbn.interval_to_ms = function(str) {
  179. var info = kbn.describe_interval(str);
  180. return info.sec * 1000 * info.count;
  181. };
  182. kbn.interval_to_seconds = function(str) {
  183. var info = kbn.describe_interval(str);
  184. return info.sec * info.count;
  185. };
  186. kbn.query_color_dot = function(color, diameter) {
  187. return (
  188. '<div class="icon-circle" style="' +
  189. ['display:inline-block', 'color:' + color, 'font-size:' + diameter + 'px'].join(';') +
  190. '"></div>'
  191. );
  192. };
  193. kbn.slugifyForUrl = function(str) {
  194. return str
  195. .toLowerCase()
  196. .replace(/[^\w ]+/g, '')
  197. .replace(/ +/g, '-');
  198. };
  199. kbn.stringToJsRegex = function(str) {
  200. if (str[0] !== '/') {
  201. return new RegExp('^' + str + '$');
  202. }
  203. var match = str.match(new RegExp('^/(.*?)/(g?i?m?y?)$'));
  204. return new RegExp(match[1], match[2]);
  205. };
  206. kbn.toFixed = function(value, decimals) {
  207. if (value === null) {
  208. return '';
  209. }
  210. var factor = decimals ? Math.pow(10, Math.max(0, decimals)) : 1;
  211. var formatted = String(Math.round(value * factor) / factor);
  212. // if exponent return directly
  213. if (formatted.indexOf('e') !== -1 || value === 0) {
  214. return formatted;
  215. }
  216. // If tickDecimals was specified, ensure that we have exactly that
  217. // much precision; otherwise default to the value's own precision.
  218. if (decimals != null) {
  219. var decimalPos = formatted.indexOf('.');
  220. var precision = decimalPos === -1 ? 0 : formatted.length - decimalPos - 1;
  221. if (precision < decimals) {
  222. return (precision ? formatted : formatted + '.') + String(factor).substr(1, decimals - precision);
  223. }
  224. }
  225. return formatted;
  226. };
  227. kbn.toFixedScaled = function(value, decimals, scaledDecimals, additionalDecimals, ext) {
  228. if (scaledDecimals === null) {
  229. return kbn.toFixed(value, decimals) + ext;
  230. } else {
  231. return kbn.toFixed(value, scaledDecimals + additionalDecimals) + ext;
  232. }
  233. };
  234. kbn.roundValue = function(num, decimals) {
  235. if (num === null) {
  236. return null;
  237. }
  238. var n = Math.pow(10, decimals);
  239. var formatted = (n * num).toFixed(decimals);
  240. return Math.round(parseFloat(formatted)) / n;
  241. };
  242. ///// FORMAT FUNCTION CONSTRUCTORS /////
  243. kbn.formatBuilders = {};
  244. // Formatter which always appends a fixed unit string to the value. No
  245. // scaling of the value is performed.
  246. kbn.formatBuilders.fixedUnit = function(unit) {
  247. return function(size, decimals) {
  248. if (size === null) {
  249. return '';
  250. }
  251. return kbn.toFixed(size, decimals) + ' ' + unit;
  252. };
  253. };
  254. // Formatter which scales the unit string geometrically according to the given
  255. // numeric factor. Repeatedly scales the value down by the factor until it is
  256. // less than the factor in magnitude, or the end of the array is reached.
  257. kbn.formatBuilders.scaledUnits = function(factor, extArray) {
  258. return function(size, decimals, scaledDecimals) {
  259. if (size === null) {
  260. return '';
  261. }
  262. var steps = 0;
  263. var limit = extArray.length;
  264. while (Math.abs(size) >= factor) {
  265. steps++;
  266. size /= factor;
  267. if (steps >= limit) {
  268. return 'NA';
  269. }
  270. }
  271. if (steps > 0 && scaledDecimals !== null) {
  272. decimals = scaledDecimals + 3 * steps;
  273. }
  274. return kbn.toFixed(size, decimals) + extArray[steps];
  275. };
  276. };
  277. // Extension of the scaledUnits builder which uses SI decimal prefixes. If an
  278. // offset is given, it adjusts the starting units at the given prefix; a value
  279. // of 0 starts at no scale; -3 drops to nano, +2 starts at mega, etc.
  280. kbn.formatBuilders.decimalSIPrefix = function(unit, offset) {
  281. var prefixes = ['n', 'µ', 'm', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
  282. prefixes = prefixes.slice(3 + (offset || 0));
  283. var units = prefixes.map(function(p) {
  284. return ' ' + p + unit;
  285. });
  286. return kbn.formatBuilders.scaledUnits(1000, units);
  287. };
  288. // Extension of the scaledUnits builder which uses SI binary prefixes. If
  289. // offset is given, it starts the units at the given prefix; otherwise, the
  290. // offset defaults to zero and the initial unit is not prefixed.
  291. kbn.formatBuilders.binarySIPrefix = function(unit, offset) {
  292. var prefixes = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'].slice(offset);
  293. var units = prefixes.map(function(p) {
  294. return ' ' + p + unit;
  295. });
  296. return kbn.formatBuilders.scaledUnits(1024, units);
  297. };
  298. // Currency formatter for prefixing a symbol onto a number. Supports scaling
  299. // up to the trillions.
  300. kbn.formatBuilders.currency = function(symbol) {
  301. var units = ['', 'K', 'M', 'B', 'T'];
  302. var scaler = kbn.formatBuilders.scaledUnits(1000, units);
  303. return function(size, decimals, scaledDecimals) {
  304. if (size === null) {
  305. return '';
  306. }
  307. var scaled = scaler(size, decimals, scaledDecimals);
  308. return symbol + scaled;
  309. };
  310. };
  311. kbn.formatBuilders.simpleCountUnit = function(symbol) {
  312. var units = ['', 'K', 'M', 'B', 'T'];
  313. var scaler = kbn.formatBuilders.scaledUnits(1000, units);
  314. return function(size, decimals, scaledDecimals) {
  315. if (size === null) {
  316. return '';
  317. }
  318. var scaled = scaler(size, decimals, scaledDecimals);
  319. return scaled + ' ' + symbol;
  320. };
  321. };
  322. ///// VALUE FORMATS /////
  323. // Dimensionless Units
  324. kbn.valueFormats.none = kbn.toFixed;
  325. kbn.valueFormats.short = kbn.formatBuilders.scaledUnits(1000, [
  326. '',
  327. ' K',
  328. ' Mil',
  329. ' Bil',
  330. ' Tri',
  331. ' Quadr',
  332. ' Quint',
  333. ' Sext',
  334. ' Sept',
  335. ]);
  336. kbn.valueFormats.dB = kbn.formatBuilders.fixedUnit('dB');
  337. kbn.valueFormats.ppm = kbn.formatBuilders.fixedUnit('ppm');
  338. kbn.valueFormats.percent = function(size, decimals) {
  339. if (size === null) {
  340. return '';
  341. }
  342. return kbn.toFixed(size, decimals) + '%';
  343. };
  344. kbn.valueFormats.percentunit = function(size, decimals) {
  345. if (size === null) {
  346. return '';
  347. }
  348. return kbn.toFixed(100 * size, decimals) + '%';
  349. };
  350. /* Formats the value to hex. Uses float if specified decimals are not 0.
  351. * There are two options, one with 0x, and one without */
  352. kbn.valueFormats.hex = function(value, decimals) {
  353. if (value == null) {
  354. return '';
  355. }
  356. return parseFloat(kbn.toFixed(value, decimals))
  357. .toString(16)
  358. .toUpperCase();
  359. };
  360. kbn.valueFormats.hex0x = function(value, decimals) {
  361. if (value == null) {
  362. return '';
  363. }
  364. var hexString = kbn.valueFormats.hex(value, decimals);
  365. if (hexString.substring(0, 1) === '-') {
  366. return '-0x' + hexString.substring(1);
  367. }
  368. return '0x' + hexString;
  369. };
  370. kbn.valueFormats.sci = function(value, decimals) {
  371. return value.toExponential(decimals);
  372. };
  373. kbn.valueFormats.locale = function(value, decimals) {
  374. return value.toLocaleString(undefined, { maximumFractionDigits: decimals });
  375. };
  376. // Currencies
  377. kbn.valueFormats.currencyUSD = kbn.formatBuilders.currency('$');
  378. kbn.valueFormats.currencyGBP = kbn.formatBuilders.currency('£');
  379. kbn.valueFormats.currencyEUR = kbn.formatBuilders.currency('€');
  380. kbn.valueFormats.currencyJPY = kbn.formatBuilders.currency('¥');
  381. kbn.valueFormats.currencyRUB = kbn.formatBuilders.currency('₽');
  382. kbn.valueFormats.currencyUAH = kbn.formatBuilders.currency('₴');
  383. kbn.valueFormats.currencyBRL = kbn.formatBuilders.currency('R$');
  384. kbn.valueFormats.currencyDKK = kbn.formatBuilders.currency('kr');
  385. kbn.valueFormats.currencyISK = kbn.formatBuilders.currency('kr');
  386. kbn.valueFormats.currencyNOK = kbn.formatBuilders.currency('kr');
  387. kbn.valueFormats.currencySEK = kbn.formatBuilders.currency('kr');
  388. // Data (Binary)
  389. kbn.valueFormats.bits = kbn.formatBuilders.binarySIPrefix('b');
  390. kbn.valueFormats.bytes = kbn.formatBuilders.binarySIPrefix('B');
  391. kbn.valueFormats.kbytes = kbn.formatBuilders.binarySIPrefix('B', 1);
  392. kbn.valueFormats.mbytes = kbn.formatBuilders.binarySIPrefix('B', 2);
  393. kbn.valueFormats.gbytes = kbn.formatBuilders.binarySIPrefix('B', 3);
  394. // Data (Decimal)
  395. kbn.valueFormats.decbits = kbn.formatBuilders.decimalSIPrefix('b');
  396. kbn.valueFormats.decbytes = kbn.formatBuilders.decimalSIPrefix('B');
  397. kbn.valueFormats.deckbytes = kbn.formatBuilders.decimalSIPrefix('B', 1);
  398. kbn.valueFormats.decmbytes = kbn.formatBuilders.decimalSIPrefix('B', 2);
  399. kbn.valueFormats.decgbytes = kbn.formatBuilders.decimalSIPrefix('B', 3);
  400. // Data Rate
  401. kbn.valueFormats.pps = kbn.formatBuilders.decimalSIPrefix('pps');
  402. kbn.valueFormats.bps = kbn.formatBuilders.decimalSIPrefix('bps');
  403. kbn.valueFormats.Bps = kbn.formatBuilders.decimalSIPrefix('Bps');
  404. kbn.valueFormats.KBs = kbn.formatBuilders.decimalSIPrefix('Bs', 1);
  405. kbn.valueFormats.Kbits = kbn.formatBuilders.decimalSIPrefix('bps', 1);
  406. kbn.valueFormats.MBs = kbn.formatBuilders.decimalSIPrefix('Bs', 2);
  407. kbn.valueFormats.Mbits = kbn.formatBuilders.decimalSIPrefix('bps', 2);
  408. kbn.valueFormats.GBs = kbn.formatBuilders.decimalSIPrefix('Bs', 3);
  409. kbn.valueFormats.Gbits = kbn.formatBuilders.decimalSIPrefix('bps', 3);
  410. // Hash Rate
  411. kbn.valueFormats.Hs = kbn.formatBuilders.decimalSIPrefix('H/s');
  412. kbn.valueFormats.KHs = kbn.formatBuilders.decimalSIPrefix('H/s', 1);
  413. kbn.valueFormats.MHs = kbn.formatBuilders.decimalSIPrefix('H/s', 2);
  414. kbn.valueFormats.GHs = kbn.formatBuilders.decimalSIPrefix('H/s', 3);
  415. kbn.valueFormats.THs = kbn.formatBuilders.decimalSIPrefix('H/s', 4);
  416. kbn.valueFormats.PHs = kbn.formatBuilders.decimalSIPrefix('H/s', 5);
  417. kbn.valueFormats.EHs = kbn.formatBuilders.decimalSIPrefix('H/s', 6);
  418. // Throughput
  419. kbn.valueFormats.ops = kbn.formatBuilders.simpleCountUnit('ops');
  420. kbn.valueFormats.rps = kbn.formatBuilders.simpleCountUnit('rps');
  421. kbn.valueFormats.wps = kbn.formatBuilders.simpleCountUnit('wps');
  422. kbn.valueFormats.iops = kbn.formatBuilders.simpleCountUnit('iops');
  423. kbn.valueFormats.opm = kbn.formatBuilders.simpleCountUnit('opm');
  424. kbn.valueFormats.rpm = kbn.formatBuilders.simpleCountUnit('rpm');
  425. kbn.valueFormats.wpm = kbn.formatBuilders.simpleCountUnit('wpm');
  426. // Energy
  427. kbn.valueFormats.watt = kbn.formatBuilders.decimalSIPrefix('W');
  428. kbn.valueFormats.kwatt = kbn.formatBuilders.decimalSIPrefix('W', 1);
  429. kbn.valueFormats.mwatt = kbn.formatBuilders.decimalSIPrefix('W', -1);
  430. kbn.valueFormats.kwattm = kbn.formatBuilders.decimalSIPrefix('W/Min', 1);
  431. kbn.valueFormats.voltamp = kbn.formatBuilders.decimalSIPrefix('VA');
  432. kbn.valueFormats.kvoltamp = kbn.formatBuilders.decimalSIPrefix('VA', 1);
  433. kbn.valueFormats.voltampreact = kbn.formatBuilders.decimalSIPrefix('var');
  434. kbn.valueFormats.kvoltampreact = kbn.formatBuilders.decimalSIPrefix('var', 1);
  435. kbn.valueFormats.watth = kbn.formatBuilders.decimalSIPrefix('Wh');
  436. kbn.valueFormats.kwatth = kbn.formatBuilders.decimalSIPrefix('Wh', 1);
  437. kbn.valueFormats.joule = kbn.formatBuilders.decimalSIPrefix('J');
  438. kbn.valueFormats.ev = kbn.formatBuilders.decimalSIPrefix('eV');
  439. kbn.valueFormats.amp = kbn.formatBuilders.decimalSIPrefix('A');
  440. kbn.valueFormats.kamp = kbn.formatBuilders.decimalSIPrefix('A', 1);
  441. kbn.valueFormats.mamp = kbn.formatBuilders.decimalSIPrefix('A', -1);
  442. kbn.valueFormats.volt = kbn.formatBuilders.decimalSIPrefix('V');
  443. kbn.valueFormats.kvolt = kbn.formatBuilders.decimalSIPrefix('V', 1);
  444. kbn.valueFormats.mvolt = kbn.formatBuilders.decimalSIPrefix('V', -1);
  445. kbn.valueFormats.dBm = kbn.formatBuilders.decimalSIPrefix('dBm');
  446. kbn.valueFormats.ohm = kbn.formatBuilders.decimalSIPrefix('Ω');
  447. kbn.valueFormats.lumens = kbn.formatBuilders.decimalSIPrefix('Lm');
  448. // Temperature
  449. kbn.valueFormats.celsius = kbn.formatBuilders.fixedUnit('°C');
  450. kbn.valueFormats.farenheit = kbn.formatBuilders.fixedUnit('°F');
  451. kbn.valueFormats.kelvin = kbn.formatBuilders.fixedUnit('K');
  452. kbn.valueFormats.humidity = kbn.formatBuilders.fixedUnit('%H');
  453. // Pressure
  454. kbn.valueFormats.pressurebar = kbn.formatBuilders.decimalSIPrefix('bar');
  455. kbn.valueFormats.pressurembar = kbn.formatBuilders.decimalSIPrefix('bar', -1);
  456. kbn.valueFormats.pressurekbar = kbn.formatBuilders.decimalSIPrefix('bar', 1);
  457. kbn.valueFormats.pressurehpa = kbn.formatBuilders.fixedUnit('hPa');
  458. kbn.valueFormats.pressurehg = kbn.formatBuilders.fixedUnit('"Hg');
  459. kbn.valueFormats.pressurepsi = kbn.formatBuilders.scaledUnits(1000, [' psi', ' ksi', ' Mpsi']);
  460. // Force
  461. kbn.valueFormats.forceNm = kbn.formatBuilders.decimalSIPrefix('Nm');
  462. kbn.valueFormats.forcekNm = kbn.formatBuilders.decimalSIPrefix('Nm', 1);
  463. kbn.valueFormats.forceN = kbn.formatBuilders.decimalSIPrefix('N');
  464. kbn.valueFormats.forcekN = kbn.formatBuilders.decimalSIPrefix('N', 1);
  465. // Length
  466. kbn.valueFormats.lengthm = kbn.formatBuilders.decimalSIPrefix('m');
  467. kbn.valueFormats.lengthmm = kbn.formatBuilders.decimalSIPrefix('m', -1);
  468. kbn.valueFormats.lengthkm = kbn.formatBuilders.decimalSIPrefix('m', 1);
  469. kbn.valueFormats.lengthmi = kbn.formatBuilders.fixedUnit('mi');
  470. kbn.valueFormats.lengthft = kbn.formatBuilders.fixedUnit('ft');
  471. // Area
  472. kbn.valueFormats.areaM2 = kbn.formatBuilders.fixedUnit('m²');
  473. kbn.valueFormats.areaF2 = kbn.formatBuilders.fixedUnit('ft²');
  474. kbn.valueFormats.areaMI2 = kbn.formatBuilders.fixedUnit('mi²');
  475. // Mass
  476. kbn.valueFormats.massmg = kbn.formatBuilders.decimalSIPrefix('g', -1);
  477. kbn.valueFormats.massg = kbn.formatBuilders.decimalSIPrefix('g');
  478. kbn.valueFormats.masskg = kbn.formatBuilders.decimalSIPrefix('g', 1);
  479. kbn.valueFormats.masst = kbn.formatBuilders.fixedUnit('t');
  480. // Velocity
  481. kbn.valueFormats.velocityms = kbn.formatBuilders.fixedUnit('m/s');
  482. kbn.valueFormats.velocitykmh = kbn.formatBuilders.fixedUnit('km/h');
  483. kbn.valueFormats.velocitymph = kbn.formatBuilders.fixedUnit('mph');
  484. kbn.valueFormats.velocityknot = kbn.formatBuilders.fixedUnit('kn');
  485. // Acceleration
  486. kbn.valueFormats.accMS2 = kbn.formatBuilders.fixedUnit('m/sec²');
  487. kbn.valueFormats.accFS2 = kbn.formatBuilders.fixedUnit('f/sec²');
  488. kbn.valueFormats.accG = kbn.formatBuilders.fixedUnit('g');
  489. // Volume
  490. kbn.valueFormats.litre = kbn.formatBuilders.decimalSIPrefix('L');
  491. kbn.valueFormats.mlitre = kbn.formatBuilders.decimalSIPrefix('L', -1);
  492. kbn.valueFormats.m3 = kbn.formatBuilders.fixedUnit('m3');
  493. kbn.valueFormats.dm3 = kbn.formatBuilders.fixedUnit('dm3');
  494. kbn.valueFormats.gallons = kbn.formatBuilders.fixedUnit('gal');
  495. // Flow
  496. kbn.valueFormats.flowgpm = kbn.formatBuilders.fixedUnit('gpm');
  497. kbn.valueFormats.flowcms = kbn.formatBuilders.fixedUnit('cms');
  498. kbn.valueFormats.flowcfs = kbn.formatBuilders.fixedUnit('cfs');
  499. kbn.valueFormats.flowcfm = kbn.formatBuilders.fixedUnit('cfm');
  500. // Angle
  501. kbn.valueFormats.degree = kbn.formatBuilders.fixedUnit('°');
  502. kbn.valueFormats.radian = kbn.formatBuilders.fixedUnit('rad');
  503. kbn.valueFormats.grad = kbn.formatBuilders.fixedUnit('grad');
  504. // Radiation
  505. kbn.valueFormats.radbq = kbn.formatBuilders.decimalSIPrefix('Bq');
  506. kbn.valueFormats.radci = kbn.formatBuilders.decimalSIPrefix('Ci');
  507. kbn.valueFormats.radgy = kbn.formatBuilders.decimalSIPrefix('Gy');
  508. kbn.valueFormats.radrad = kbn.formatBuilders.decimalSIPrefix('rad');
  509. kbn.valueFormats.radsv = kbn.formatBuilders.decimalSIPrefix('Sv');
  510. kbn.valueFormats.radrem = kbn.formatBuilders.decimalSIPrefix('rem');
  511. kbn.valueFormats.radexpckg = kbn.formatBuilders.decimalSIPrefix('C/kg');
  512. kbn.valueFormats.radr = kbn.formatBuilders.decimalSIPrefix('R');
  513. kbn.valueFormats.radsvh = kbn.formatBuilders.decimalSIPrefix('Sv/h');
  514. // Time
  515. kbn.valueFormats.hertz = kbn.formatBuilders.decimalSIPrefix('Hz');
  516. kbn.valueFormats.ms = function(size, decimals, scaledDecimals) {
  517. if (size === null) {
  518. return '';
  519. }
  520. if (Math.abs(size) < 1000) {
  521. return kbn.toFixed(size, decimals) + ' ms';
  522. } else if (Math.abs(size) < 60000) {
  523. // Less than 1 min
  524. return kbn.toFixedScaled(size / 1000, decimals, scaledDecimals, 3, ' s');
  525. } else if (Math.abs(size) < 3600000) {
  526. // Less than 1 hour, devide in minutes
  527. return kbn.toFixedScaled(size / 60000, decimals, scaledDecimals, 5, ' min');
  528. } else if (Math.abs(size) < 86400000) {
  529. // Less than one day, devide in hours
  530. return kbn.toFixedScaled(size / 3600000, decimals, scaledDecimals, 7, ' hour');
  531. } else if (Math.abs(size) < 31536000000) {
  532. // Less than one year, devide in days
  533. return kbn.toFixedScaled(size / 86400000, decimals, scaledDecimals, 8, ' day');
  534. }
  535. return kbn.toFixedScaled(size / 31536000000, decimals, scaledDecimals, 10, ' year');
  536. };
  537. kbn.valueFormats.s = function(size, decimals, scaledDecimals) {
  538. if (size === null) {
  539. return '';
  540. }
  541. // Less than 1 µs, devide in ns
  542. if (Math.abs(size) < 0.000001) {
  543. return kbn.toFixedScaled(size * 1e9, decimals, scaledDecimals - decimals, -9, ' ns');
  544. }
  545. // Less than 1 ms, devide in µs
  546. if (Math.abs(size) < 0.001) {
  547. return kbn.toFixedScaled(size * 1e6, decimals, scaledDecimals - decimals, -6, ' µs');
  548. }
  549. // Less than 1 second, devide in ms
  550. if (Math.abs(size) < 1) {
  551. return kbn.toFixedScaled(size * 1e3, decimals, scaledDecimals - decimals, -3, ' ms');
  552. }
  553. if (Math.abs(size) < 60) {
  554. return kbn.toFixed(size, decimals) + ' s';
  555. } else if (Math.abs(size) < 3600) {
  556. // Less than 1 hour, devide in minutes
  557. return kbn.toFixedScaled(size / 60, decimals, scaledDecimals, 1, ' min');
  558. } else if (Math.abs(size) < 86400) {
  559. // Less than one day, devide in hours
  560. return kbn.toFixedScaled(size / 3600, decimals, scaledDecimals, 4, ' hour');
  561. } else if (Math.abs(size) < 604800) {
  562. // Less than one week, devide in days
  563. return kbn.toFixedScaled(size / 86400, decimals, scaledDecimals, 5, ' day');
  564. } else if (Math.abs(size) < 31536000) {
  565. // Less than one year, devide in week
  566. return kbn.toFixedScaled(size / 604800, decimals, scaledDecimals, 6, ' week');
  567. }
  568. return kbn.toFixedScaled(size / 3.15569e7, decimals, scaledDecimals, 7, ' year');
  569. };
  570. kbn.valueFormats['µs'] = function(size, decimals, scaledDecimals) {
  571. if (size === null) {
  572. return '';
  573. }
  574. if (Math.abs(size) < 1000) {
  575. return kbn.toFixed(size, decimals) + ' µs';
  576. } else if (Math.abs(size) < 1000000) {
  577. return kbn.toFixedScaled(size / 1000, decimals, scaledDecimals, 3, ' ms');
  578. } else {
  579. return kbn.toFixedScaled(size / 1000000, decimals, scaledDecimals, 6, ' s');
  580. }
  581. };
  582. kbn.valueFormats.ns = function(size, decimals, scaledDecimals) {
  583. if (size === null) {
  584. return '';
  585. }
  586. if (Math.abs(size) < 1000) {
  587. return kbn.toFixed(size, decimals) + ' ns';
  588. } else if (Math.abs(size) < 1000000) {
  589. return kbn.toFixedScaled(size / 1000, decimals, scaledDecimals, 3, ' µs');
  590. } else if (Math.abs(size) < 1000000000) {
  591. return kbn.toFixedScaled(size / 1000000, decimals, scaledDecimals, 6, ' ms');
  592. } else if (Math.abs(size) < 60000000000) {
  593. return kbn.toFixedScaled(size / 1000000000, decimals, scaledDecimals, 9, ' s');
  594. } else {
  595. return kbn.toFixedScaled(size / 60000000000, decimals, scaledDecimals, 12, ' min');
  596. }
  597. };
  598. kbn.valueFormats.m = function(size, decimals, scaledDecimals) {
  599. if (size === null) {
  600. return '';
  601. }
  602. if (Math.abs(size) < 60) {
  603. return kbn.toFixed(size, decimals) + ' min';
  604. } else if (Math.abs(size) < 1440) {
  605. return kbn.toFixedScaled(size / 60, decimals, scaledDecimals, 2, ' hour');
  606. } else if (Math.abs(size) < 10080) {
  607. return kbn.toFixedScaled(size / 1440, decimals, scaledDecimals, 3, ' day');
  608. } else if (Math.abs(size) < 604800) {
  609. return kbn.toFixedScaled(size / 10080, decimals, scaledDecimals, 4, ' week');
  610. } else {
  611. return kbn.toFixedScaled(size / 5.25948e5, decimals, scaledDecimals, 5, ' year');
  612. }
  613. };
  614. kbn.valueFormats.h = function(size, decimals, scaledDecimals) {
  615. if (size === null) {
  616. return '';
  617. }
  618. if (Math.abs(size) < 24) {
  619. return kbn.toFixed(size, decimals) + ' hour';
  620. } else if (Math.abs(size) < 168) {
  621. return kbn.toFixedScaled(size / 24, decimals, scaledDecimals, 2, ' day');
  622. } else if (Math.abs(size) < 8760) {
  623. return kbn.toFixedScaled(size / 168, decimals, scaledDecimals, 3, ' week');
  624. } else {
  625. return kbn.toFixedScaled(size / 8760, decimals, scaledDecimals, 4, ' year');
  626. }
  627. };
  628. kbn.valueFormats.d = function(size, decimals, scaledDecimals) {
  629. if (size === null) {
  630. return '';
  631. }
  632. if (Math.abs(size) < 7) {
  633. return kbn.toFixed(size, decimals) + ' day';
  634. } else if (Math.abs(size) < 365) {
  635. return kbn.toFixedScaled(size / 7, decimals, scaledDecimals, 2, ' week');
  636. } else {
  637. return kbn.toFixedScaled(size / 365, decimals, scaledDecimals, 3, ' year');
  638. }
  639. };
  640. kbn.toDuration = function(size, decimals, timeScale) {
  641. if (size === null) {
  642. return '';
  643. }
  644. if (size === 0) {
  645. return '0 ' + timeScale + 's';
  646. }
  647. if (size < 0) {
  648. return kbn.toDuration(-size, decimals, timeScale) + ' ago';
  649. }
  650. var units = [
  651. { short: 'y', long: 'year' },
  652. { short: 'M', long: 'month' },
  653. { short: 'w', long: 'week' },
  654. { short: 'd', long: 'day' },
  655. { short: 'h', long: 'hour' },
  656. { short: 'm', long: 'minute' },
  657. { short: 's', long: 'second' },
  658. { short: 'ms', long: 'millisecond' },
  659. ];
  660. // convert $size to milliseconds
  661. // intervals_in_seconds uses seconds (duh), convert them to milliseconds here to minimize floating point errors
  662. size *=
  663. kbn.intervals_in_seconds[
  664. units.find(function(e) {
  665. return e.long === timeScale;
  666. }).short
  667. ] * 1000;
  668. var strings = [];
  669. // after first value >= 1 print only $decimals more
  670. var decrementDecimals = false;
  671. for (var i = 0; i < units.length && decimals >= 0; i++) {
  672. var interval = kbn.intervals_in_seconds[units[i].short] * 1000;
  673. var value = size / interval;
  674. if (value >= 1 || decrementDecimals) {
  675. decrementDecimals = true;
  676. var floor = Math.floor(value);
  677. var unit = units[i].long + (floor !== 1 ? 's' : '');
  678. strings.push(floor + ' ' + unit);
  679. size = size % interval;
  680. decimals--;
  681. }
  682. }
  683. return strings.join(', ');
  684. };
  685. kbn.valueFormats.dtdurationms = function(size, decimals) {
  686. return kbn.toDuration(size, decimals, 'millisecond');
  687. };
  688. kbn.valueFormats.dtdurations = function(size, decimals) {
  689. return kbn.toDuration(size, decimals, 'second');
  690. };
  691. kbn.valueFormats.dateTimeAsIso = function(epoch) {
  692. var time = moment(epoch);
  693. if (moment().isSame(epoch, 'day')) {
  694. return time.format('HH:mm:ss');
  695. }
  696. return time.format('YYYY-MM-DD HH:mm:ss');
  697. };
  698. kbn.valueFormats.dateTimeAsUS = function(epoch) {
  699. var time = moment(epoch);
  700. if (moment().isSame(epoch, 'day')) {
  701. return time.format('h:mm:ss a');
  702. }
  703. return time.format('MM/DD/YYYY h:mm:ss a');
  704. };
  705. kbn.valueFormats.dateTimeFromNow = function(epoch) {
  706. return moment(epoch).fromNow();
  707. };
  708. ///// FORMAT MENU /////
  709. kbn.getUnitFormats = function() {
  710. return [
  711. {
  712. text: 'none',
  713. submenu: [
  714. { text: 'none', value: 'none' },
  715. { text: 'short', value: 'short' },
  716. { text: 'percent (0-100)', value: 'percent' },
  717. { text: 'percent (0.0-1.0)', value: 'percentunit' },
  718. { text: 'Humidity (%H)', value: 'humidity' },
  719. { text: 'ppm', value: 'ppm' },
  720. { text: 'decibel', value: 'dB' },
  721. { text: 'hexadecimal (0x)', value: 'hex0x' },
  722. { text: 'hexadecimal', value: 'hex' },
  723. { text: 'scientific notation', value: 'sci' },
  724. { text: 'locale format', value: 'locale' },
  725. ],
  726. },
  727. {
  728. text: 'currency',
  729. submenu: [
  730. { text: 'Dollars ($)', value: 'currencyUSD' },
  731. { text: 'Pounds (£)', value: 'currencyGBP' },
  732. { text: 'Euro (€)', value: 'currencyEUR' },
  733. { text: 'Yen (¥)', value: 'currencyJPY' },
  734. { text: 'Rubles (₽)', value: 'currencyRUB' },
  735. { text: 'Hryvnias (₴)', value: 'currencyUAH' },
  736. { text: 'Real (R$)', value: 'currencyBRL' },
  737. { text: 'Danish Krone (kr)', value: 'currencyDKK' },
  738. { text: 'Icelandic Krone (kr)', value: 'currencyISK' },
  739. { text: 'Norwegian Krone (kr)', value: 'currencyNOK' },
  740. { text: 'Swedish Krone (kr)', value: 'currencySEK' },
  741. ],
  742. },
  743. {
  744. text: 'time',
  745. submenu: [
  746. { text: 'Hertz (1/s)', value: 'hertz' },
  747. { text: 'nanoseconds (ns)', value: 'ns' },
  748. { text: 'microseconds (µs)', value: 'µs' },
  749. { text: 'milliseconds (ms)', value: 'ms' },
  750. { text: 'seconds (s)', value: 's' },
  751. { text: 'minutes (m)', value: 'm' },
  752. { text: 'hours (h)', value: 'h' },
  753. { text: 'days (d)', value: 'd' },
  754. { text: 'duration (ms)', value: 'dtdurationms' },
  755. { text: 'duration (s)', value: 'dtdurations' },
  756. ],
  757. },
  758. {
  759. text: 'date & time',
  760. submenu: [
  761. { text: 'YYYY-MM-DD HH:mm:ss', value: 'dateTimeAsIso' },
  762. { text: 'DD/MM/YYYY h:mm:ss a', value: 'dateTimeAsUS' },
  763. { text: 'From Now', value: 'dateTimeFromNow' },
  764. ],
  765. },
  766. {
  767. text: 'data (IEC)',
  768. submenu: [
  769. { text: 'bits', value: 'bits' },
  770. { text: 'bytes', value: 'bytes' },
  771. { text: 'kibibytes', value: 'kbytes' },
  772. { text: 'mebibytes', value: 'mbytes' },
  773. { text: 'gibibytes', value: 'gbytes' },
  774. ],
  775. },
  776. {
  777. text: 'data (Metric)',
  778. submenu: [
  779. { text: 'bits', value: 'decbits' },
  780. { text: 'bytes', value: 'decbytes' },
  781. { text: 'kilobytes', value: 'deckbytes' },
  782. { text: 'megabytes', value: 'decmbytes' },
  783. { text: 'gigabytes', value: 'decgbytes' },
  784. ],
  785. },
  786. {
  787. text: 'data rate',
  788. submenu: [
  789. { text: 'packets/sec', value: 'pps' },
  790. { text: 'bits/sec', value: 'bps' },
  791. { text: 'bytes/sec', value: 'Bps' },
  792. { text: 'kilobits/sec', value: 'Kbits' },
  793. { text: 'kilobytes/sec', value: 'KBs' },
  794. { text: 'megabits/sec', value: 'Mbits' },
  795. { text: 'megabytes/sec', value: 'MBs' },
  796. { text: 'gigabytes/sec', value: 'GBs' },
  797. { text: 'gigabits/sec', value: 'Gbits' },
  798. ],
  799. },
  800. {
  801. text: 'hash rate',
  802. submenu: [
  803. {text: 'hashes/sec', value: 'Hs'},
  804. {text: 'kilohashes/sec', value: 'KHs'},
  805. {text: 'megahashes/sec', value: 'MHs'},
  806. {text: 'gigahashes/sec', value: 'GHs'},
  807. {text: 'terahashes/sec', value: 'THs'},
  808. {text: 'petahashes/sec', value: 'PHs'},
  809. {text: 'exahashes/sec', value: 'EHs'},
  810. ],
  811. },
  812. {
  813. text: 'throughput',
  814. submenu: [
  815. { text: 'ops/sec (ops)', value: 'ops' },
  816. { text: 'reads/sec (rps)', value: 'rps' },
  817. { text: 'writes/sec (wps)', value: 'wps' },
  818. { text: 'I/O ops/sec (iops)', value: 'iops' },
  819. { text: 'ops/min (opm)', value: 'opm' },
  820. { text: 'reads/min (rpm)', value: 'rpm' },
  821. { text: 'writes/min (wpm)', value: 'wpm' },
  822. ],
  823. },
  824. {
  825. text: 'length',
  826. submenu: [
  827. { text: 'millimetre (mm)', value: 'lengthmm' },
  828. { text: 'meter (m)', value: 'lengthm' },
  829. { text: 'feet (ft)', value: 'lengthft' },
  830. { text: 'kilometer (km)', value: 'lengthkm' },
  831. { text: 'mile (mi)', value: 'lengthmi' },
  832. ],
  833. },
  834. {
  835. text: 'area',
  836. submenu: [
  837. { text: 'Square Meters (m²)', value: 'areaM2' },
  838. { text: 'Square Feet (ft²)', value: 'areaF2' },
  839. { text: 'Square Miles (mi²)', value: 'areaMI2' },
  840. ],
  841. },
  842. {
  843. text: 'mass',
  844. submenu: [
  845. { text: 'milligram (mg)', value: 'massmg' },
  846. { text: 'gram (g)', value: 'massg' },
  847. { text: 'kilogram (kg)', value: 'masskg' },
  848. { text: 'metric ton (t)', value: 'masst' },
  849. ],
  850. },
  851. {
  852. text: 'velocity',
  853. submenu: [
  854. { text: 'm/s', value: 'velocityms' },
  855. { text: 'km/h', value: 'velocitykmh' },
  856. { text: 'mph', value: 'velocitymph' },
  857. { text: 'knot (kn)', value: 'velocityknot' },
  858. ],
  859. },
  860. {
  861. text: 'volume',
  862. submenu: [
  863. { text: 'millilitre', value: 'mlitre' },
  864. { text: 'litre', value: 'litre' },
  865. { text: 'cubic metre', value: 'm3' },
  866. { text: 'cubic decimetre', value: 'dm3' },
  867. { text: 'gallons', value: 'gallons' },
  868. ],
  869. },
  870. {
  871. text: 'energy',
  872. submenu: [
  873. { text: 'Watt (W)', value: 'watt' },
  874. { text: 'Kilowatt (kW)', value: 'kwatt' },
  875. { text: 'Milliwatt (mW)', value: 'mwatt' },
  876. { text: 'Volt-ampere (VA)', value: 'voltamp' },
  877. { text: 'Kilovolt-ampere (kVA)', value: 'kvoltamp' },
  878. { text: 'Volt-ampere reactive (var)', value: 'voltampreact' },
  879. { text: 'Kilovolt-ampere reactive (kvar)', value: 'kvoltampreact' },
  880. { text: 'Watt-hour (Wh)', value: 'watth' },
  881. { text: 'Kilowatt-hour (kWh)', value: 'kwatth' },
  882. { text: 'Kilowatt-min (kWm)', value: 'kwattm' },
  883. { text: 'Joule (J)', value: 'joule' },
  884. { text: 'Electron volt (eV)', value: 'ev' },
  885. { text: 'Ampere (A)', value: 'amp' },
  886. { text: 'Kiloampere (kA)', value: 'kamp' },
  887. { text: 'Milliampere (mA)', value: 'mamp' },
  888. { text: 'Volt (V)', value: 'volt' },
  889. { text: 'Kilovolt (kV)', value: 'kvolt' },
  890. { text: 'Millivolt (mV)', value: 'mvolt' },
  891. { text: 'Decibel-milliwatt (dBm)', value: 'dBm' },
  892. { text: 'Ohm (Ω)', value: 'ohm' },
  893. { text: 'Lumens (Lm)', value: 'lumens' },
  894. ],
  895. },
  896. {
  897. text: 'temperature',
  898. submenu: [
  899. { text: 'Celsius (°C)', value: 'celsius' },
  900. { text: 'Farenheit (°F)', value: 'farenheit' },
  901. { text: 'Kelvin (K)', value: 'kelvin' },
  902. ],
  903. },
  904. {
  905. text: 'pressure',
  906. submenu: [
  907. { text: 'Millibars', value: 'pressurembar' },
  908. { text: 'Bars', value: 'pressurebar' },
  909. { text: 'Kilobars', value: 'pressurekbar' },
  910. { text: 'Hectopascals', value: 'pressurehpa' },
  911. { text: 'Inches of mercury', value: 'pressurehg' },
  912. { text: 'PSI', value: 'pressurepsi' },
  913. ],
  914. },
  915. {
  916. text: 'force',
  917. submenu: [
  918. { text: 'Newton-meters (Nm)', value: 'forceNm' },
  919. { text: 'Kilonewton-meters (kNm)', value: 'forcekNm' },
  920. { text: 'Newtons (N)', value: 'forceN' },
  921. { text: 'Kilonewtons (kN)', value: 'forcekN' },
  922. ],
  923. },
  924. {
  925. text: 'flow',
  926. submenu: [
  927. { text: 'Gallons/min (gpm)', value: 'flowgpm' },
  928. { text: 'Cubic meters/sec (cms)', value: 'flowcms' },
  929. { text: 'Cubic feet/sec (cfs)', value: 'flowcfs' },
  930. { text: 'Cubic feet/min (cfm)', value: 'flowcfm' },
  931. ],
  932. },
  933. {
  934. text: 'angle',
  935. submenu: [
  936. { text: 'Degrees (°)', value: 'degree' },
  937. { text: 'Radians', value: 'radian' },
  938. { text: 'Gradian', value: 'grad' },
  939. ],
  940. },
  941. {
  942. text: 'acceleration',
  943. submenu: [
  944. { text: 'Meters/sec²', value: 'accMS2' },
  945. { text: 'Feet/sec²', value: 'accFS2' },
  946. { text: 'G unit', value: 'accG' },
  947. ],
  948. },
  949. {
  950. text: 'radiation',
  951. submenu: [
  952. { text: 'Becquerel (Bq)', value: 'radbq' },
  953. { text: 'curie (Ci)', value: 'radci' },
  954. { text: 'Gray (Gy)', value: 'radgy' },
  955. { text: 'rad', value: 'radrad' },
  956. { text: 'Sievert (Sv)', value: 'radsv' },
  957. { text: 'rem', value: 'radrem' },
  958. { text: 'Exposure (C/kg)', value: 'radexpckg' },
  959. { text: 'roentgen (R)', value: 'radr' },
  960. { text: 'Sievert/hour (Sv/h)', value: 'radsvh' },
  961. ],
  962. },
  963. ];
  964. };
  965. export default kbn;