European number formats in Kibana

Hi There
How can we set the number to be displayed properly according to our national standards?
We use dot as thousand separator and comma as decimal pointer (10.510,75)

(Editing in settings "format:number:defaultPattern" obviously cannot produce the correct format)

/Lars

Unfortunately, this isn't currently possible. Here's the enhancement request to follow: https://github.com/elastic/kibana/issues/9228

Hi Lukas
Is there any way to hardcode a change inside Kibana?

You could write a custom plugin of type hack that defines and sets a locale. See http://numeraljs.com/#locales.

Great I will try this. Where in the Kibana code would the hack have to be injected?

This is a raw and hardcode solution on Kibana 5.4 that worked for me:

  • open the file src/ui/public/stringify/types/_numeral.js

  • find in the file the conversion function:

    Numeral.prototype._convert = function (val) {
    if (val === -Infinity) return '-∞';
    if (val === +Infinity) return '+∞';
    if (typeof val !== 'number') {
    val = parseFloat(val);
    }

    if (isNaN(val)) return '';

    return numeral.set(val).format(this.param('pattern'));
    };

-Change it to:

Numeral.prototype._convert = function (val) {
if (val === -Infinity) return '-∞';
if (val === +Infinity) return '+∞';
if (typeof val !== 'number') {
  val = parseFloat(val);
}

if (isNaN(val)) return '';

return numeral.set(val).format(this.param('pattern')).replace(",","t").replace(".",",").replace("t",".");
};

-to apply these changes delete whole content of optimize/bundles directory then restart the Kibana (bundles will be regenerated by kibana at startup)

Again this is a hack solution I hope the globalization feature will be available soon in Kibana...

Hi Paolo
Thanks for the hack. It only replaces the first comma in case of more commas, so we just reworked it a little to this which replaces all occurences.

return numeral.set(val).format(this.param('pattern')).split('.').map((e) => e.replace(new RegExp(',', 'g'), '.')).join(',');

ATB
Lars

2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.