-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Lens] Allow number formatting within Lens #56253
[Lens] Allow number formatting within Lens #56253
Conversation
Pinging @elastic/kibana-app (Team:KibanaApp) |
@@ -83,6 +83,7 @@ export type IFieldFormatId = FIELD_FORMAT_IDS | string; | |||
|
|||
export type IFieldFormatType = (new (params?: any, getConfig?: GetConfigFn) => FieldFormat) & { | |||
id: IFieldFormatId; | |||
title?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Title is already present on formatters, but the type was not set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this needs to be optional? It seems from the FieldFormat
class, that the title
is the same as id
and fieldType
always present, and could just be a mandatory string
.
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for app arch (just looking at the update to IFieldFormatType
)
Tagging for product/design review @AlonaNadler @cchaos Related issue: #53535 This doesn't yet implement a tab-based UI, I expect that to be coming soon for use in Y-axis styling |
@wylieconlon Can you explain what "Default format (Number)" is? I would have suspected that we don't need to explicitly say "Default" but that we'd just automatically select "Number". So then there'd be no distinction between "Default" and "Custom" numbers, but just a single "Number" option that always shows the decimals option. When I select a price field, the formatter option still says "Default format (Number)" when in fact it's showing as a currency. |
So we don't have a currency formatter, the Number formatter is being used
with a custom pattern. So your understanding is correct, the default shows:
1. If the field has a custom format in the index pattern, we display its
name
2. If there is no custom format, then there is a space-wide setting which
assigns formats to type. Most of the time it's Number, but it could be
String or something else.
…On Thu, Jan 30, 2020 at 4:12 PM Caroline Horn ***@***.***> wrote:
@wylieconlon <https://github.com/wylieconlon> Can you explain what
"Default format (Number)" is? I would have suspected that we don't need to
explicitly say "Default" but that we'd just automatically select "Number".
[image: Screen Shot 2020-01-30 at 15 59 48 PM]
<https://user-images.githubusercontent.com/549577/73489983-951c8700-4379-11ea-8e16-2a802d81e761.png>
So then there'd be no distinction between "Default" and "Custom" numbers,
but just a single "Number" option that always shows the decimals option.
------------------------------
When I select a price field, the formatter option still says "Default
format (Number)" when in fact it's showing as a currency.
[image: Screen Shot 2020-01-30 at 15 50 32 PM]
<https://user-images.githubusercontent.com/549577/73490099-ceed8d80-4379-11ea-8f54-0f2672ccdbd1.png>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#56253?email_source=notifications&email_token=AAFCW23QWRHQTD7XTV33XRLRAM7DLA5CNFSM4KM3X3N2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKMSLUQ#issuecomment-580462034>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFCW277ESYLFU3XNF3CZJ3RAM7DLANCNFSM4KM3X3NQ>
.
|
That's also why there is a difference between the Default and the "Custom number" formatter, because "Custom number" as implemented here only lets you customize the number of decimal places, while in the Management -> Index pattern settings, you can use a numeral.js pattern. |
Great work @wylieconlon
|
Thanks for the feedback! Responses inline.
Talked with you about this, what I've implemented is the maximum number of decimal places, and what you are asking for is the minimum number of decimal places. We need to talk more about this before making a decision.
Will fix this.
We're using the same format, so this is already happening.
I'll look into this, I think we can apply the format to some suggestions but not others. If we are using the same field then it should be doable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on our meeting, I've added some review notes.
x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/format_selector.tsx
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/format_selector.tsx
Outdated
Show resolved
Hide resolved
<> | ||
<EuiFormRow | ||
label={i18n.translate('xpack.lens.indexPattern.columnFormatLabel', { | ||
defaultMessage: 'Formatter', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultMessage: 'Formatter', | |
defaultMessage: 'Display values as', |
@AlonaNadler Trying to better describe the input via the label here without being to verbose. But I think "Formatter" is wrong, since it just changes the the way the values are displayed not actual formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying "Display format" because I do think it's important to be consistent with the rest of Kibana. We call this "Format" everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do Value format
instead?
x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/format_selector.tsx
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/format_selector.tsx
Outdated
Show resolved
Hide resolved
|
Okay, both 2 and 3 are related to the same overall issue, which is that our formatters don't have any context. It's especially noticeable because the bytes formatter scales itself between orders of magnitude, but affects dates as well. For example: #7539 #51227 I don't expect to solve these issues in this PR, as it's something the bytes formatter has across Kibana. Feel free to open an issue to discuss the problem of bytes formatting on the Y axis. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks good from my end! 🎉
I will be doing a follow up PR closer to FF for any style tweaks.
To do: Change from |
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* [Lens] Allow custom number formats on dimensions * Fix merge issues * Text and decimal changes from review * Persist number format across operations * Respond to review comments * Change label * Add persistence * Fix import * 2 decimals * Persist number formatting on drop too Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
…dex-server-side * 'master' of github.com:elastic/kibana: (34 commits) [Upgrade Assistant] Remove "boom" from reindex service (elastic#58715) [data] Clean up QueryStringInput unit tests (elastic#58704) [SIEM] Detection Fix typo in Adobe Hijack Persistence rule (elastic#58804) Restores [SIEM][CASE] Init Configure Case Page (elastic#58121) (elastic#58924) Skips additional failing Ingest Manager integration tests Skips failing Ingest Manager integration tests Move dev tools styles to NP (elastic#58855) change to have kibana --ssl cli option use more recent certs (elastic#57933) disable failing suite (elastic#58942) Don't start pollEsNodesVersion unless someone subscribes (elastic#56923) Do not write UUID file during optimize process (elastic#58899) [Endpoint] Task/add nav bar (elastic#58604) [Metric Alerts] Add backend support for multiple expressions per alert (elastic#58672) [Metrics Alerts] Fix alerting on a rate aggregation (elastic#58789) disable flaky suite (elastic#55953) Revert "[SIEM] apollo@3 (elastic#51926)" and "[SIEM][CASE] Init Confi… (elastic#58806) [resubmit] Prep agg types for new platform (elastic#58893) [Lens] Allow number formatting within Lens (elastic#56253) [Autocomplete] Use settings from config rather than UI settings (elastic#58784) Improve action and trigger types (elastic#58657) ... # Conflicts: # x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts
Release note
Lens now allows you to format numbers as
Percent
orBytes
from within Lens, with a setting for the number of decimal places to show:Detail
The original scope of this change was larger, but contains two breaking changes that aren't possible to mitigate: #53972
The reduced-scope change introduces an expression function called
lens_format_column columnId="a" format="bytes" maxDecimals=3
which sets theformatHint
property of thekibana_datatable
. This function is responsible for generatingnumeral.js
patterns, such as0,0.[000]%
, depending on the formatter and number of decimals selected.Users do not get to set
numeral.js
patterns directly, because this lets us change the implementation toIntl.NumberFormat
in 8.0 without causing another breaking change.Checklist