Hi,
I'm trying to create a new field formatter for Kibana 5.4.1 that somehow mixes the "Color" and "Number" formatters. Specifically, I want to have a Color formatter that also rounds the numbers to three decimal points, in order to avoid huge numbers when calculating aggregations such as averages. To do that, I have slightly changed the "_convert" function in Color.js file under "/opt/kibana/src/ui/public/stringify/types", adding a substring function call:
_Color.prototype._convert = {
html(val) {
const color = _.findLast(this.param('colors'), ({ range }) => {
if (!range) return;
const [start, end] = range.split(':');
return val >= Number(start) && val <= Number(end);
});
if (!color) return _.asPrettyString(val);
// Substring the value before formatting it val = val.substring(0,3); const styleColor = color.text ? `color: ${color.text};` : ''; const styleBackgroundColor = color.background ? `background-color: ${color.background};` : ''; return `<span style="${styleColor}${styleBackgroundColor}">${_.escape(val)}</span>`; } };
However, after modifying the file and reloading the page and index, the field format remains the same (the numbers are colored (after configuring the formatter) but not rounded. Am I missing something here?
Any help would be greatly appreciated.