Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6a1a77e
[Formatters] Add new field formatters
wylieconlon Jan 2, 2020
3785cc3
Merge remote-tracking branch 'origin/master' into add-formatters
wylieconlon Jan 7, 2020
5682ade
Remove locale override. Support browser locale.
wylieconlon Jan 9, 2020
44f02c0
Merge remote-tracking branch 'origin/master' into add-formatters
wylieconlon Jan 9, 2020
c600fee
i18n currency names in field format editor
Jan 10, 2020
c834a3e
Merge remote-tracking branch 'origin/master' into add-formatters
wylieconlon Jan 10, 2020
aba8e7c
Add migration and update tests
wylieconlon Jan 10, 2020
f9d89df
Merge remote-tracking branch 'origin/master' into add-formatters
wylieconlon Jan 10, 2020
2a6eced
Remove unused
wylieconlon Jan 10, 2020
47ec996
Remove deprecated settings use
wylieconlon Jan 10, 2020
4f3175a
Fix lint error
wylieconlon Jan 10, 2020
8679335
Merge remote-tracking branch 'origin/master' into add-formatters
wylieconlon Jan 13, 2020
4e43465
Stop formatting numbers in CSV export
wylieconlon Jan 13, 2020
e217a48
Add advanced setting for max decimals
wylieconlon Jan 13, 2020
3af88d1
Move currency to i18n
wylieconlon Jan 13, 2020
bb44874
Merge remote-tracking branch 'origin/master' into add-formatters
wylieconlon Jan 14, 2020
fa1797c
Add snapshots for format editors
wylieconlon Jan 14, 2020
a7c3d17
Fix tests
wylieconlon Jan 14, 2020
4ffa130
Merge remote-tracking branch 'origin/master' into add-formatters
wylieconlon Jan 14, 2020
d2e32ee
Merge remote-tracking branch 'origin/master' into add-formatters
wylieconlon Jan 15, 2020
d1a1fdb
Merge remote-tracking branch 'origin/master' into add-formatters
wylieconlon Jan 17, 2020
3fbdfb0
Update reporting to include locale
wylieconlon Jan 17, 2020
8ec6d98
Merge remote-tracking branch 'origin/master' into add-formatters
wylieconlon Jan 17, 2020
6b34bac
Remove settings change
wylieconlon Jan 17, 2020
ec25c3e
Fix integration test that was using custom formatting
wylieconlon Jan 17, 2020
3754f11
Fix test again
wylieconlon Jan 17, 2020
381c584
Merge remote-tracking branch 'origin/master' into add-formatters
wylieconlon Jan 21, 2020
fa1d6d9
Fix tests again
wylieconlon Jan 21, 2020
1efcfc2
Merge remote-tracking branch 'origin/master' into add-formatters
wylieconlon Jan 21, 2020
b96444a
More test fixing
wylieconlon Jan 21, 2020
fbbfaf5
More test fixes
wylieconlon Jan 22, 2020
aeefd35
Hopefully final tweaks
wylieconlon Jan 22, 2020
40f6c5c
Merge remote-tracking branch 'origin/master' into add-formatters
wylieconlon Jan 22, 2020
f7bb12e
More fixes
wylieconlon Jan 22, 2020
ecd2198
Fix tests
wylieconlon Jan 22, 2020
ff46904
Fix tests
wylieconlon Jan 22, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docs/management/advanced-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ adapt to the interval between measurements. Keys are http://en.wikipedia.org/wik
`fields:popularLimit`:: The top N most popular fields to show.
`filterEditor:suggestValues`:: Set this property to `false` to prevent the filter editor from suggesting values for fields.
`filters:pinnedByDefault`:: Set this property to `true` to make filters have a global state (be pinned) by default.
`format:bytes:defaultPattern`:: The default http://numeraljs.com/[numeral format] for the "bytes" format.
`format:currency:defaultPattern`:: The default http://numeraljs.com/[numeral format] for the "currency" format.
`format:defaultTypeMap`:: A map of the default format name for each field type. Field types that are not explicitly
mentioned use "\_default_".
`format:number:defaultLocale`:: The http://numeraljs.com/[numeral language] locale.
`format:currency:defaultCurrency`:: The currency used for all currency formatting by default. Currency can be changed for a single field using the index management section. If a currency is unlisted here, it can also be set in the index management section.
`format:defaultLocale`:: Default number display locale. This locale will affect number formatting for most formatters. When "detect" is chosen, it will use the locale preference from the browser when formatting numbers.
`format:number:defaultLocale`:: The http://numeraljs.com/[numeral language] locale. This affects the custom numeral.js formatter and the bytes formatter.
`format:number:defaultPattern`:: The default http://numeraljs.com/[numeral format] for the "number" format.
`format:percent:defaultPattern`:: The default http://numeraljs.com/[numeral format] for the "percent" format.
`histogram:barTarget`:: When date histograms use the `auto` interval, Kibana attempts to generate this number of bars.
`histogram:maxBars`:: Date histograms are not generated with more bars than the value of this property, scaling values
when necessary.
Expand Down
24 changes: 15 additions & 9 deletions docs/management/managing-fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ The fields for the index pattern are listed in a table. Click a column header to
the *Controls* button in the rightmost column for a given field to edit the field's properties. You can manually set
the field's format from the *Format* drop-down. Format options vary based on the field's type.

You can also set the field's popularity value in the *Popularity* text entry box to any desired value. Click the
*Update Field* button to confirm your changes or *Cancel* to return to the list of fields.
You can also set the field's popularity value in the *Popularity* text entry box to any desired value. If a field has a
popularity value, it will be sorted higher in Discover. Click the *Update Field* button to confirm your changes or
*Cancel* to return to the list of fields.

Kibana has field formatters for the following field types:

Expand Down Expand Up @@ -46,26 +47,31 @@ include::field-formatters/string-formatter.asciidoc[]
[[field-formatters-numeric]]
=== Numeric Field Formatters

Numeric fields support the `Url`, `Bytes`, `Duration`, `Number`, `Percentage`, `String`, and `Color` formatters.
Numeric fields support the `Default Number`, `Percent`, `Bytes`, `Short Number`, `Currency`, `Custom Numeral.js format`,
`Duration`, `String`, `Url`, and `Color` formatters.

include::field-formatters/url-formatter.asciidoc[]
The advanced setting `format:defaultLocale` affects the localization of numbers with these formats: `Default Number`,
`Percent`, `Short Number`, and `Currency`. The advanced setting `format:number:defaultLocale` affects the localization of
numbers with the `Bytes` and `Custom Numeral.js format`.

include::field-formatters/string-formatter.asciidoc[]
The `Custom Numeral.js format` enables customization of display using the https://adamwdraper.github.io/Numeral-js/[numeral.js]
standard format definitions.

include::field-formatters/duration-formatter.asciidoc[]

include::field-formatters/color-formatter.asciidoc[]
include::field-formatters/url-formatter.asciidoc[]

include::field-formatters/string-formatter.asciidoc[]

The `Bytes`, `Number`, and `Percentage` formatters enable you to choose the display formats of numbers in this field using
the https://adamwdraper.github.io/Numeral-js/[numeral.js] standard format definitions.
include::field-formatters/color-formatter.asciidoc[]

[[scripted-fields]]
=== Scripted Fields

Scripted fields compute data on the fly from the data in your Elasticsearch indices. Scripted field data is shown on
the Discover tab as part of the document data, and you can use scripted fields in your visualizations.
Scripted field values are computed at query time so they aren't indexed and cannot be searched using Kibana's default
query language. However they can be queried using Kibana's new <<kuery-query, experimental query language>>. Scripted
query language. However they can be queried using Kibana's new <<kuery-query, query language>>. Scripted
fields are also supported in the filter bar.

WARNING: Computing data on the fly with scripted fields can be very resource intensive and can have a direct impact on
Expand Down
2 changes: 2 additions & 0 deletions docs/user/reporting/development/pdf-integration.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface jobParameters {
objectType: string;
title: string;
browserTimezone: string;
browserLocales: string[];
relativeUrls: string[];
layout: {
id: string;
Expand All @@ -23,6 +24,7 @@ interface jobParameters {
----

`jobParameters.browserTimezone` is a string that appears in the tz database
`jobParameters.browserLocales` is an ordered array of locale codes such as "en-US"
`jobParameters.layout.id` presently only accepts "print" and "preserve_layout"
`jobParameters.layout.dimensions` is only currently used by "preserve_layout"

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"@elastic/eui": "18.2.1",
"@elastic/filesaver": "1.1.2",
"@elastic/good": "8.1.1-kibana2",
"@elastic/numeral": "2.3.3",
"@elastic/numeral": "2.3.5",
"@elastic/request-crypto": "^1.0.2",
"@elastic/ui-ace": "0.2.3",
"@hapi/wreck": "^15.0.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-i18n/src/angular/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export class I18nProvider implements angular.IServiceProvider {
public setFormats = i18n.setFormats;
public getFormats = i18n.getFormats;
public getRegisteredLocales = i18n.getRegisteredLocales;
public getKnownCurrencies = i18n.getKnownCurrencies;
public getKnownLocales = i18n.getKnownLocales;
public getKnownLocalesWithDisplay = i18n.getKnownLocalesWithDisplay;
public init = i18n.init;
public load = i18n.load;
public $get = () => i18n.translate;
Expand Down
276 changes: 275 additions & 1 deletion packages/kbn-i18n/src/core/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ import { Translation } from '../translation';
import { Formats, formats as EN_FORMATS } from './formats';
import { hasValues, isObject, isString, mergeAll } from './helper';
import { isPseudoLocale, translateUsingPseudoLocale } from './pseudo_locale';
import { knownLocales } from './known_locales';

// Add all locale data to `IntlMessageFormat`.
import './locales.js';
// This has a side effect./register_localest of registering locale data to numeral-js
import './register_locales';

const EN_LOCALE = 'en';
const translationsForLocale: Record<string, Translation> = {};
Expand Down Expand Up @@ -163,6 +165,278 @@ export function getRegisteredLocales() {
return Object.keys(translationsForLocale);
}

/**
* Top 35 most traded currencies per https://en.wikipedia.org/wiki/Template:Most_traded_currencies
* This list is not a full list of currencies, but the ISO standard full list of currencies
* does not provide some of the amenities of this Wiki list- a mashup of sources would be required
* to provide country name, currency name, and currency symbol.
* The full ISO reference: https://www.currency-iso.org/en/home/tables/table-a1.html
*/
export function getKnownCurrencies() {
return [
{
name: translate('common.ui.fieldEditor.currency.currencies.USD', {
defaultMessage: 'United States dollar',
}),
code: 'USD',
symbol: 'US$',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.EUR', {
defaultMessage: 'Euro',
}),
code: 'EUR',
symbol: '€',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.JPY', {
defaultMessage: 'Japanese yen',
}),
code: 'JPY',
symbol: '¥',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.GBP', {
defaultMessage: 'Pound sterling',
}),
code: 'GBP',
symbol: '£',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.AUD', {
defaultMessage: 'Australian dollar',
}),
code: 'AUD',
symbol: 'A$',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.CAD', {
defaultMessage: 'Canadian dollar',
}),
code: 'CAD',
symbol: 'C$',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.CHF', {
defaultMessage: 'Swiss franc',
}),
code: 'CHF',
symbol: 'CHF',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.CNY', {
defaultMessage: 'Renminbi',
}),
code: 'CNY',
symbol: '元',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.HKD', {
defaultMessage: 'Hong Kong dollar',
}),
code: 'HKD',
symbol: 'HK$',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.NZD', {
defaultMessage: 'New Zealand dollar',
}),
code: 'NZD',
symbol: 'NZ$',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.SEK', {
defaultMessage: 'Swedish krona',
}),
code: 'SEK',
symbol: 'kr',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.KRW', {
defaultMessage: 'South Korean won',
}),
code: 'KRW',
symbol: '₩',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.SGD', {
defaultMessage: 'Singapore dollar',
}),
code: 'SGD',
symbol: 'S$',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.NOK', {
defaultMessage: 'Norwegian krone',
}),
code: 'NOK',
symbol: 'kr',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.MXN', {
defaultMessage: 'Mexican peso',
}),
code: 'MXN',
symbol: '$',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.INR', {
defaultMessage: 'Indian rupee',
}),
code: 'INR',
symbol: '₹',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.RUB', {
defaultMessage: 'Russian ruble',
}),
code: 'RUB',
symbol: '₽',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.ZAR', {
defaultMessage: 'South African rand',
}),
code: 'ZAR',
symbol: 'R',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.TRY', {
defaultMessage: 'Turkish lira',
}),
code: 'TRY',
symbol: '₺',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.BRL', {
defaultMessage: 'Brazilian real',
}),
code: 'BRL',
symbol: 'R$',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.TWD', {
defaultMessage: 'New Taiwan dollar',
}),
code: 'TWD',
symbol: 'NT$',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.DKK', {
defaultMessage: 'Danish krone',
}),
code: 'DKK',
symbol: 'kr',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.PLN', {
defaultMessage: 'Polish zloty',
}),
code: 'PLN',
symbol: 'zł',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.THB', {
defaultMessage: 'Thai baht',
}),
code: 'THB',
symbol: '฿',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.IDR', {
defaultMessage: 'Indonesian rupiah',
}),
code: 'IDR',
symbol: 'Rp',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.HUF', {
defaultMessage: 'Hungarian forint',
}),
code: 'HUF',
symbol: 'Ft',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.CZK', {
defaultMessage: 'Czech koruna',
}),
code: 'CZK',
symbol: 'Kč',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.ILS', {
defaultMessage: 'Israeli new shekel',
}),
code: 'ILS',
symbol: '₪',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.CLP', {
defaultMessage: 'Chilean peso',
}),
code: 'CLP',
symbol: 'CLP$',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.PHP', {
defaultMessage: 'Philippine peso',
}),
code: 'PHP',
symbol: '₱',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.AED', {
defaultMessage: 'UAE dirham',
}),
code: 'AED',
symbol: 'د.إ',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.COP', {
defaultMessage: 'Colombian peso',
}),
code: 'COP',
symbol: 'COL$',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.SAR', {
defaultMessage: 'Saudi riyal',
}),
code: 'SAR',
symbol: '﷼',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.MYR', {
defaultMessage: 'Malaysian ringgit',
}),
code: 'MYR',
symbol: 'RM',
},
{
name: translate('common.ui.fieldEditor.currency.currencies.RON', {
defaultMessage: 'Romanian leu',
}),
code: 'RON',
symbol: 'L',
},
];
}

/**
* Returns array of locales that can be used with i18n, even if there is no translation.
* This could be used for number formatting.
*/
export function getKnownLocales() {
return Object.keys(knownLocales);
}

/**
* Returns { [locale]: { name: [display], native: '', currency: '' } } map.
*/
export function getKnownLocalesWithDisplay() {
return knownLocales;
}

interface TranslateArguments {
values?: Record<string, string | number | boolean | Date | null | undefined>;
defaultMessage: string;
Expand Down
Loading