-
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] Add suffix formatter #128246
[Lens] Add suffix formatter #128246
Conversation
Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors) |
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.
Tested and it works great. Only thing I didn't test is the following bullet (because I don't know how 😅 )
Can also be applied if time scaling is active (will nest to suffixes, one for the time unit, one for the user supplied string)
@@ -19,17 +19,18 @@ export interface BaseIndexPatternColumn extends Operation { | |||
timeShift?: string; | |||
} | |||
|
|||
export interface FormatParams { | |||
export interface LensFormatParams { |
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.
Do I understand correctly that this interface defines configuration to format values for display to the user?
If so, we could consider calling it DisplayFormatConfig
or something. I'm not sure what we gain by prepending Lens
since we're already in the lens
plugin.
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.
Maybe ValueFormatConfig
?
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 like it!
Yeah, it feels weird for me. But I also find weird that we put formatter in between the number and time scaling unit.. I don't have a good solution with a suffix. I think it still can be useful for the user, and maybe in the future we'll solve this issue with template instead. |
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.
Tested it and it works as expected in Chrome. However, I am just wondering from the product side how are we going to expand on this issue - are we planning on adding prefix too, or template formatting similar to TSVB? Do we accept the limitations that come with this solution? (and the weird behavior for time scaling too?)
If at some point we would be planning on replacing it with template, maybe it makes sense to prepare saved object shape for it by replacing the part
"format": {
"id": "number",
"params": {
"decimals": 0,
"suffix": "$"
}
}
to:
"format": {
"id": "number",
"params": {
"decimals": 0,
"template": "{{value}}$"
}
}
and parse the template
to get the suffix
? Just a thought though, maybe I am overthinking it.
If the product is ok with this solution, I am too :)
We are definitely in need of a larger scope refactoring of how formatting works in general today in Kibana overall. There have been some early discussions, but it's not planned for the medium term - this PR (just allowing the suffix) is meant as a stopgap measure to solve a certain common use case now until we can revisit the larger issue. We can wait until @ghudgins gets back before merging to make sure this is the direction we want to take now. |
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
++ similar to everyone else I agree that it's a bit weird but I do think it's better to be predictable--I would hate for a user who is using % to not be able to find this setting. I think it's good to go as is |
Fixes #88402
This PR adds a simple way to add a suffix to a formatter:
Open question: It's a little weird to mix it with percentage or bytes formatter - should it only be shown for the "number" formatter?