|
@@ -5,13 +5,13 @@ const kbn: any = {};
|
|
|
|
|
|
|
|
kbn.valueFormats = {};
|
|
kbn.valueFormats = {};
|
|
|
|
|
|
|
|
-kbn.regexEscape = function(value) {
|
|
|
|
|
|
|
+kbn.regexEscape = value => {
|
|
|
return value.replace(/[\\^$*+?.()|[\]{}\/]/g, '\\$&');
|
|
return value.replace(/[\\^$*+?.()|[\]{}\/]/g, '\\$&');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
///// HELPER FUNCTIONS /////
|
|
///// HELPER FUNCTIONS /////
|
|
|
|
|
|
|
|
-kbn.round_interval = function(interval) {
|
|
|
|
|
|
|
+kbn.round_interval = interval => {
|
|
|
switch (true) {
|
|
switch (true) {
|
|
|
// 0.015s
|
|
// 0.015s
|
|
|
case interval < 15:
|
|
case interval < 15:
|
|
@@ -102,7 +102,7 @@ kbn.round_interval = function(interval) {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.secondsToHms = function(seconds) {
|
|
|
|
|
|
|
+kbn.secondsToHms = seconds => {
|
|
|
const numyears = Math.floor(seconds / 31536000);
|
|
const numyears = Math.floor(seconds / 31536000);
|
|
|
if (numyears) {
|
|
if (numyears) {
|
|
|
return numyears + 'y';
|
|
return numyears + 'y';
|
|
@@ -131,7 +131,7 @@ kbn.secondsToHms = function(seconds) {
|
|
|
return 'less than a millisecond'; //'just now' //or other string you like;
|
|
return 'less than a millisecond'; //'just now' //or other string you like;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.secondsToHhmmss = function(seconds) {
|
|
|
|
|
|
|
+kbn.secondsToHhmmss = seconds => {
|
|
|
const strings = [];
|
|
const strings = [];
|
|
|
const numhours = Math.floor(seconds / 3600);
|
|
const numhours = Math.floor(seconds / 3600);
|
|
|
const numminutes = Math.floor((seconds % 3600) / 60);
|
|
const numminutes = Math.floor((seconds % 3600) / 60);
|
|
@@ -142,11 +142,11 @@ kbn.secondsToHhmmss = function(seconds) {
|
|
|
return strings.join(':');
|
|
return strings.join(':');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.to_percent = function(nr, outof) {
|
|
|
|
|
|
|
+kbn.to_percent = (nr, outof) => {
|
|
|
return Math.floor(nr / outof * 10000) / 100 + '%';
|
|
return Math.floor(nr / outof * 10000) / 100 + '%';
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.addslashes = function(str) {
|
|
|
|
|
|
|
+kbn.addslashes = str => {
|
|
|
str = str.replace(/\\/g, '\\\\');
|
|
str = str.replace(/\\/g, '\\\\');
|
|
|
str = str.replace(/\'/g, "\\'");
|
|
str = str.replace(/\'/g, "\\'");
|
|
|
str = str.replace(/\"/g, '\\"');
|
|
str = str.replace(/\"/g, '\\"');
|
|
@@ -168,7 +168,7 @@ kbn.intervals_in_seconds = {
|
|
|
ms: 0.001,
|
|
ms: 0.001,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.calculateInterval = function(range, resolution, lowLimitInterval) {
|
|
|
|
|
|
|
+kbn.calculateInterval = (range, resolution, lowLimitInterval) => {
|
|
|
let lowLimitMs = 1; // 1 millisecond default low limit
|
|
let lowLimitMs = 1; // 1 millisecond default low limit
|
|
|
let intervalMs;
|
|
let intervalMs;
|
|
|
|
|
|
|
@@ -190,7 +190,7 @@ kbn.calculateInterval = function(range, resolution, lowLimitInterval) {
|
|
|
};
|
|
};
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.describe_interval = function(str) {
|
|
|
|
|
|
|
+kbn.describe_interval = str => {
|
|
|
const matches = str.match(kbn.interval_regex);
|
|
const matches = str.match(kbn.interval_regex);
|
|
|
if (!matches || !_.has(kbn.intervals_in_seconds, matches[2])) {
|
|
if (!matches || !_.has(kbn.intervals_in_seconds, matches[2])) {
|
|
|
throw new Error('Invalid interval string, expecting a number followed by one of "Mwdhmsy"');
|
|
throw new Error('Invalid interval string, expecting a number followed by one of "Mwdhmsy"');
|
|
@@ -203,17 +203,17 @@ kbn.describe_interval = function(str) {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.interval_to_ms = function(str) {
|
|
|
|
|
|
|
+kbn.interval_to_ms = str => {
|
|
|
const info = kbn.describe_interval(str);
|
|
const info = kbn.describe_interval(str);
|
|
|
return info.sec * 1000 * info.count;
|
|
return info.sec * 1000 * info.count;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.interval_to_seconds = function(str) {
|
|
|
|
|
|
|
+kbn.interval_to_seconds = str => {
|
|
|
const info = kbn.describe_interval(str);
|
|
const info = kbn.describe_interval(str);
|
|
|
return info.sec * info.count;
|
|
return info.sec * info.count;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.query_color_dot = function(color, diameter) {
|
|
|
|
|
|
|
+kbn.query_color_dot = (color, diameter) => {
|
|
|
return (
|
|
return (
|
|
|
'<div class="icon-circle" style="' +
|
|
'<div class="icon-circle" style="' +
|
|
|
['display:inline-block', 'color:' + color, 'font-size:' + diameter + 'px'].join(';') +
|
|
['display:inline-block', 'color:' + color, 'font-size:' + diameter + 'px'].join(';') +
|
|
@@ -221,14 +221,14 @@ kbn.query_color_dot = function(color, diameter) {
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.slugifyForUrl = function(str) {
|
|
|
|
|
|
|
+kbn.slugifyForUrl = str => {
|
|
|
return str
|
|
return str
|
|
|
.toLowerCase()
|
|
.toLowerCase()
|
|
|
.replace(/[^\w ]+/g, '')
|
|
.replace(/[^\w ]+/g, '')
|
|
|
.replace(/ +/g, '-');
|
|
.replace(/ +/g, '-');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.stringToJsRegex = function(str) {
|
|
|
|
|
|
|
+kbn.stringToJsRegex = str => {
|
|
|
if (str[0] !== '/') {
|
|
if (str[0] !== '/') {
|
|
|
return new RegExp('^' + str + '$');
|
|
return new RegExp('^' + str + '$');
|
|
|
}
|
|
}
|
|
@@ -237,7 +237,7 @@ kbn.stringToJsRegex = function(str) {
|
|
|
return new RegExp(match[1], match[2]);
|
|
return new RegExp(match[1], match[2]);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.toFixed = function(value, decimals) {
|
|
|
|
|
|
|
+kbn.toFixed = (value, decimals) => {
|
|
|
if (value === null) {
|
|
if (value === null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -263,7 +263,7 @@ kbn.toFixed = function(value, decimals) {
|
|
|
return formatted;
|
|
return formatted;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.toFixedScaled = function(value, decimals, scaledDecimals, additionalDecimals, ext) {
|
|
|
|
|
|
|
+kbn.toFixedScaled = (value, decimals, scaledDecimals, additionalDecimals, ext) => {
|
|
|
if (scaledDecimals === null) {
|
|
if (scaledDecimals === null) {
|
|
|
return kbn.toFixed(value, decimals) + ext;
|
|
return kbn.toFixed(value, decimals) + ext;
|
|
|
} else {
|
|
} else {
|
|
@@ -271,7 +271,7 @@ kbn.toFixedScaled = function(value, decimals, scaledDecimals, additionalDecimals
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.roundValue = function(num, decimals) {
|
|
|
|
|
|
|
+kbn.roundValue = (num, decimals) => {
|
|
|
if (num === null) {
|
|
if (num === null) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
@@ -286,8 +286,8 @@ kbn.formatBuilders = {};
|
|
|
|
|
|
|
|
// Formatter which always appends a fixed unit string to the value. No
|
|
// Formatter which always appends a fixed unit string to the value. No
|
|
|
// scaling of the value is performed.
|
|
// scaling of the value is performed.
|
|
|
-kbn.formatBuilders.fixedUnit = function(unit) {
|
|
|
|
|
- return function(size, decimals) {
|
|
|
|
|
|
|
+kbn.formatBuilders.fixedUnit = unit => {
|
|
|
|
|
+ return (size, decimals) => {
|
|
|
if (size === null) {
|
|
if (size === null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -298,8 +298,8 @@ kbn.formatBuilders.fixedUnit = function(unit) {
|
|
|
// Formatter which scales the unit string geometrically according to the given
|
|
// Formatter which scales the unit string geometrically according to the given
|
|
|
// numeric factor. Repeatedly scales the value down by the factor until it is
|
|
// numeric factor. Repeatedly scales the value down by the factor until it is
|
|
|
// less than the factor in magnitude, or the end of the array is reached.
|
|
// less than the factor in magnitude, or the end of the array is reached.
|
|
|
-kbn.formatBuilders.scaledUnits = function(factor, extArray) {
|
|
|
|
|
- return function(size, decimals, scaledDecimals) {
|
|
|
|
|
|
|
+kbn.formatBuilders.scaledUnits = (factor, extArray) => {
|
|
|
|
|
+ return (size, decimals, scaledDecimals) => {
|
|
|
if (size === null) {
|
|
if (size === null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -327,10 +327,10 @@ kbn.formatBuilders.scaledUnits = function(factor, extArray) {
|
|
|
// Extension of the scaledUnits builder which uses SI decimal prefixes. If an
|
|
// Extension of the scaledUnits builder which uses SI decimal prefixes. If an
|
|
|
// offset is given, it adjusts the starting units at the given prefix; a value
|
|
// offset is given, it adjusts the starting units at the given prefix; a value
|
|
|
// of 0 starts at no scale; -3 drops to nano, +2 starts at mega, etc.
|
|
// of 0 starts at no scale; -3 drops to nano, +2 starts at mega, etc.
|
|
|
-kbn.formatBuilders.decimalSIPrefix = function(unit, offset) {
|
|
|
|
|
|
|
+kbn.formatBuilders.decimalSIPrefix = (unit, offset) => {
|
|
|
let prefixes = ['n', 'µ', 'm', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
|
|
let prefixes = ['n', 'µ', 'm', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
|
|
|
prefixes = prefixes.slice(3 + (offset || 0));
|
|
prefixes = prefixes.slice(3 + (offset || 0));
|
|
|
- const units = prefixes.map(function(p) {
|
|
|
|
|
|
|
+ const units = prefixes.map(p => {
|
|
|
return ' ' + p + unit;
|
|
return ' ' + p + unit;
|
|
|
});
|
|
});
|
|
|
return kbn.formatBuilders.scaledUnits(1000, units);
|
|
return kbn.formatBuilders.scaledUnits(1000, units);
|
|
@@ -339,9 +339,9 @@ kbn.formatBuilders.decimalSIPrefix = function(unit, offset) {
|
|
|
// Extension of the scaledUnits builder which uses SI binary prefixes. If
|
|
// Extension of the scaledUnits builder which uses SI binary prefixes. If
|
|
|
// offset is given, it starts the units at the given prefix; otherwise, the
|
|
// offset is given, it starts the units at the given prefix; otherwise, the
|
|
|
// offset defaults to zero and the initial unit is not prefixed.
|
|
// offset defaults to zero and the initial unit is not prefixed.
|
|
|
-kbn.formatBuilders.binarySIPrefix = function(unit, offset) {
|
|
|
|
|
|
|
+kbn.formatBuilders.binarySIPrefix = (unit, offset) => {
|
|
|
const prefixes = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'].slice(offset);
|
|
const prefixes = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'].slice(offset);
|
|
|
- const units = prefixes.map(function(p) {
|
|
|
|
|
|
|
+ const units = prefixes.map(p => {
|
|
|
return ' ' + p + unit;
|
|
return ' ' + p + unit;
|
|
|
});
|
|
});
|
|
|
return kbn.formatBuilders.scaledUnits(1024, units);
|
|
return kbn.formatBuilders.scaledUnits(1024, units);
|
|
@@ -349,10 +349,10 @@ kbn.formatBuilders.binarySIPrefix = function(unit, offset) {
|
|
|
|
|
|
|
|
// Currency formatter for prefixing a symbol onto a number. Supports scaling
|
|
// Currency formatter for prefixing a symbol onto a number. Supports scaling
|
|
|
// up to the trillions.
|
|
// up to the trillions.
|
|
|
-kbn.formatBuilders.currency = function(symbol) {
|
|
|
|
|
|
|
+kbn.formatBuilders.currency = symbol => {
|
|
|
const units = ['', 'K', 'M', 'B', 'T'];
|
|
const units = ['', 'K', 'M', 'B', 'T'];
|
|
|
const scaler = kbn.formatBuilders.scaledUnits(1000, units);
|
|
const scaler = kbn.formatBuilders.scaledUnits(1000, units);
|
|
|
- return function(size, decimals, scaledDecimals) {
|
|
|
|
|
|
|
+ return (size, decimals, scaledDecimals) => {
|
|
|
if (size === null) {
|
|
if (size === null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -361,10 +361,10 @@ kbn.formatBuilders.currency = function(symbol) {
|
|
|
};
|
|
};
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.formatBuilders.simpleCountUnit = function(symbol) {
|
|
|
|
|
|
|
+kbn.formatBuilders.simpleCountUnit = symbol => {
|
|
|
const units = ['', 'K', 'M', 'B', 'T'];
|
|
const units = ['', 'K', 'M', 'B', 'T'];
|
|
|
const scaler = kbn.formatBuilders.scaledUnits(1000, units);
|
|
const scaler = kbn.formatBuilders.scaledUnits(1000, units);
|
|
|
- return function(size, decimals, scaledDecimals) {
|
|
|
|
|
|
|
+ return (size, decimals, scaledDecimals) => {
|
|
|
if (size === null) {
|
|
if (size === null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -390,14 +390,14 @@ kbn.valueFormats.short = kbn.formatBuilders.scaledUnits(1000, [
|
|
|
]);
|
|
]);
|
|
|
kbn.valueFormats.dB = kbn.formatBuilders.fixedUnit('dB');
|
|
kbn.valueFormats.dB = kbn.formatBuilders.fixedUnit('dB');
|
|
|
|
|
|
|
|
-kbn.valueFormats.percent = function(size, decimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.percent = (size, decimals) => {
|
|
|
if (size === null) {
|
|
if (size === null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
|
return kbn.toFixed(size, decimals) + '%';
|
|
return kbn.toFixed(size, decimals) + '%';
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.percentunit = function(size, decimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.percentunit = (size, decimals) => {
|
|
|
if (size === null) {
|
|
if (size === null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -407,7 +407,7 @@ kbn.valueFormats.percentunit = function(size, decimals) {
|
|
|
/* Formats the value to hex. Uses float if specified decimals are not 0.
|
|
/* Formats the value to hex. Uses float if specified decimals are not 0.
|
|
|
* There are two options, one with 0x, and one without */
|
|
* There are two options, one with 0x, and one without */
|
|
|
|
|
|
|
|
-kbn.valueFormats.hex = function(value, decimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.hex = (value, decimals) => {
|
|
|
if (value == null) {
|
|
if (value == null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -416,7 +416,7 @@ kbn.valueFormats.hex = function(value, decimals) {
|
|
|
.toUpperCase();
|
|
.toUpperCase();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.hex0x = function(value, decimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.hex0x = (value, decimals) => {
|
|
|
if (value == null) {
|
|
if (value == null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -427,11 +427,11 @@ kbn.valueFormats.hex0x = function(value, decimals) {
|
|
|
return '0x' + hexString;
|
|
return '0x' + hexString;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.sci = function(value, decimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.sci = (value, decimals) => {
|
|
|
return value.toExponential(decimals);
|
|
return value.toExponential(decimals);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.locale = function(value, decimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.locale = (value, decimals) => {
|
|
|
return value.toLocaleString(undefined, { maximumFractionDigits: decimals });
|
|
return value.toLocaleString(undefined, { maximumFractionDigits: decimals });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -618,7 +618,7 @@ kbn.valueFormats.congNm3 = kbn.formatBuilders.fixedUnit('g/Nm³');
|
|
|
// Time
|
|
// Time
|
|
|
kbn.valueFormats.hertz = kbn.formatBuilders.decimalSIPrefix('Hz');
|
|
kbn.valueFormats.hertz = kbn.formatBuilders.decimalSIPrefix('Hz');
|
|
|
|
|
|
|
|
-kbn.valueFormats.ms = function(size, decimals, scaledDecimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.ms = (size, decimals, scaledDecimals) => {
|
|
|
if (size === null) {
|
|
if (size === null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -642,7 +642,7 @@ kbn.valueFormats.ms = function(size, decimals, scaledDecimals) {
|
|
|
return kbn.toFixedScaled(size / 31536000000, decimals, scaledDecimals, 10, ' year');
|
|
return kbn.toFixedScaled(size / 31536000000, decimals, scaledDecimals, 10, ' year');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.s = function(size, decimals, scaledDecimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.s = (size, decimals, scaledDecimals) => {
|
|
|
if (size === null) {
|
|
if (size === null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -679,7 +679,7 @@ kbn.valueFormats.s = function(size, decimals, scaledDecimals) {
|
|
|
return kbn.toFixedScaled(size / 3.15569e7, decimals, scaledDecimals, 7, ' year');
|
|
return kbn.toFixedScaled(size / 3.15569e7, decimals, scaledDecimals, 7, ' year');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats['µs'] = function(size, decimals, scaledDecimals) {
|
|
|
|
|
|
|
+kbn.valueFormats['µs'] = (size, decimals, scaledDecimals) => {
|
|
|
if (size === null) {
|
|
if (size === null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -693,7 +693,7 @@ kbn.valueFormats['µs'] = function(size, decimals, scaledDecimals) {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.ns = function(size, decimals, scaledDecimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.ns = (size, decimals, scaledDecimals) => {
|
|
|
if (size === null) {
|
|
if (size === null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -711,7 +711,7 @@ kbn.valueFormats.ns = function(size, decimals, scaledDecimals) {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.m = function(size, decimals, scaledDecimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.m = (size, decimals, scaledDecimals) => {
|
|
|
if (size === null) {
|
|
if (size === null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -729,7 +729,7 @@ kbn.valueFormats.m = function(size, decimals, scaledDecimals) {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.h = function(size, decimals, scaledDecimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.h = (size, decimals, scaledDecimals) => {
|
|
|
if (size === null) {
|
|
if (size === null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -745,7 +745,7 @@ kbn.valueFormats.h = function(size, decimals, scaledDecimals) {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.d = function(size, decimals, scaledDecimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.d = (size, decimals, scaledDecimals) => {
|
|
|
if (size === null) {
|
|
if (size === null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -759,7 +759,7 @@ kbn.valueFormats.d = function(size, decimals, scaledDecimals) {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.toDuration = function(size, decimals, timeScale) {
|
|
|
|
|
|
|
+kbn.toDuration = (size, decimals, timeScale) => {
|
|
|
if (size === null) {
|
|
if (size === null) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -784,7 +784,7 @@ kbn.toDuration = function(size, decimals, timeScale) {
|
|
|
// intervals_in_seconds uses seconds (duh), convert them to milliseconds here to minimize floating point errors
|
|
// intervals_in_seconds uses seconds (duh), convert them to milliseconds here to minimize floating point errors
|
|
|
size *=
|
|
size *=
|
|
|
kbn.intervals_in_seconds[
|
|
kbn.intervals_in_seconds[
|
|
|
- units.find(function(e) {
|
|
|
|
|
|
|
+ units.find(e => {
|
|
|
return e.long === timeScale;
|
|
return e.long === timeScale;
|
|
|
}).short
|
|
}).short
|
|
|
] * 1000;
|
|
] * 1000;
|
|
@@ -808,23 +808,23 @@ kbn.toDuration = function(size, decimals, timeScale) {
|
|
|
return strings.join(', ');
|
|
return strings.join(', ');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.dtdurationms = function(size, decimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.dtdurationms = (size, decimals) => {
|
|
|
return kbn.toDuration(size, decimals, 'millisecond');
|
|
return kbn.toDuration(size, decimals, 'millisecond');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.dtdurations = function(size, decimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.dtdurations = (size, decimals) => {
|
|
|
return kbn.toDuration(size, decimals, 'second');
|
|
return kbn.toDuration(size, decimals, 'second');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.dthms = function(size, decimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.dthms = (size, decimals) => {
|
|
|
return kbn.secondsToHhmmss(size);
|
|
return kbn.secondsToHhmmss(size);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.timeticks = function(size, decimals, scaledDecimals) {
|
|
|
|
|
|
|
+kbn.valueFormats.timeticks = (size, decimals, scaledDecimals) => {
|
|
|
return kbn.valueFormats.s(size / 100, decimals, scaledDecimals);
|
|
return kbn.valueFormats.s(size / 100, decimals, scaledDecimals);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.dateTimeAsIso = function(epoch, isUtc) {
|
|
|
|
|
|
|
+kbn.valueFormats.dateTimeAsIso = (epoch, isUtc) => {
|
|
|
const time = isUtc ? moment.utc(epoch) : moment(epoch);
|
|
const time = isUtc ? moment.utc(epoch) : moment(epoch);
|
|
|
|
|
|
|
|
if (moment().isSame(epoch, 'day')) {
|
|
if (moment().isSame(epoch, 'day')) {
|
|
@@ -833,7 +833,7 @@ kbn.valueFormats.dateTimeAsIso = function(epoch, isUtc) {
|
|
|
return time.format('YYYY-MM-DD HH:mm:ss');
|
|
return time.format('YYYY-MM-DD HH:mm:ss');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.dateTimeAsUS = function(epoch, isUtc) {
|
|
|
|
|
|
|
+kbn.valueFormats.dateTimeAsUS = (epoch, isUtc) => {
|
|
|
const time = isUtc ? moment.utc(epoch) : moment(epoch);
|
|
const time = isUtc ? moment.utc(epoch) : moment(epoch);
|
|
|
|
|
|
|
|
if (moment().isSame(epoch, 'day')) {
|
|
if (moment().isSame(epoch, 'day')) {
|
|
@@ -842,14 +842,14 @@ kbn.valueFormats.dateTimeAsUS = function(epoch, isUtc) {
|
|
|
return time.format('MM/DD/YYYY h:mm:ss a');
|
|
return time.format('MM/DD/YYYY h:mm:ss a');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-kbn.valueFormats.dateTimeFromNow = function(epoch, isUtc) {
|
|
|
|
|
|
|
+kbn.valueFormats.dateTimeFromNow = (epoch, isUtc) => {
|
|
|
const time = isUtc ? moment.utc(epoch) : moment(epoch);
|
|
const time = isUtc ? moment.utc(epoch) : moment(epoch);
|
|
|
return time.fromNow();
|
|
return time.fromNow();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
///// FORMAT MENU /////
|
|
///// FORMAT MENU /////
|
|
|
|
|
|
|
|
-kbn.getUnitFormats = function() {
|
|
|
|
|
|
|
+kbn.getUnitFormats = () => {
|
|
|
return [
|
|
return [
|
|
|
{
|
|
{
|
|
|
text: 'none',
|
|
text: 'none',
|