Skip to content
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] Improved range formatter #80132

Merged
merged 36 commits into from
Oct 27, 2020

Conversation

dej611
Copy link
Contributor

@dej611 dej611 commented Oct 12, 2020

Summary

This PR is a proposal for a new range formatter format.

  • ✨ The new format can be expressed using the params property in the setup payload.
    • A new arrow_right template has been added
  • ❓ The range formatter now has some logic to handle specific Infinity scenarios
  • ♻️ Reworked the format information propagation
    • Nested formatters are now supported. As for now custom arguments need to be mapped to pass the expression pipeline
  • ✨ Value format field is not enabled in the dimension panel for both base and custom ranges
    • both base and custom intervals values can be formatted
  • 🐛 Chart label format now match custom default range label one
  • 🔀 Harmonised formatter with custom labels code

Screenshot 2020-10-15 at 16 46 01

Screenshot 2020-10-15 at 16 44 21

Screenshot 2020-10-15 at 17 44 46

Screenshot 2020-10-15 at 16 44 52

Screenshot 2020-10-15 at 16 44 36

Screenshot 2020-10-15 at 16 45 32

<title>Initial proposal</title> Screenshot 2020-10-12 at 13 17 14

I would also propose to clean a bit the popover style and remove the mathematical notation from it, just to keep it clean and consistent with the new label format (not implemented yet):

Screenshot 2020-10-12 at 13 13 47

Fixes: #77881

Checklist

Delete any items that are not applicable to this PR.

@dej611
Copy link
Contributor Author

dej611 commented Oct 13, 2020

cc @AlonaNadler I've used the dash format here, is that ok?
@cchaos what do you think of the simplified range popover without the symbols?

@AlonaNadler
Copy link

Yes looks good thanks @dej611

@cchaos
Copy link
Contributor

cchaos commented Oct 13, 2020

I definitely ok with removing those symbols. I would go a bit further to and reduce the width of the inputs a bit. They're quite large for a number input. I'd say like half the size would suffice.

@dej611 dej611 marked this pull request as ready for review October 16, 2020 10:47
@dej611 dej611 requested a review from a team October 16, 2020 10:47
@dej611 dej611 requested review from a team as code owners October 16, 2020 10:47
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@dej611
Copy link
Contributor Author

dej611 commented Oct 16, 2020

@elasticmachine merge upstream

@flash1293
Copy link
Contributor

flash1293 commented Oct 22, 2020

This is the only thing I'm seeing in Lens (installed the logs sample data, no other index patterns around):
Screenshot 2020-10-22 at 15 24 59

It seems like the logic we put in place to remap the field formats to a serialized format don't always work and need a safeguard (x-pack/plugins/lens/public/indexpattern_datasource/loader.ts): https://github.com/elastic/kibana/pull/80132/files#diff-eff297f41b4d66e06e5f7c181f338648e9521022c6945b734cb06b37b2c39bc3R109

@dej611
Copy link
Contributor Author

dej611 commented Oct 22, 2020

I'm working to add more tests on that side to detect changes of this kind in the future 👍

@dej611
Copy link
Contributor Author

dej611 commented Oct 22, 2020

This is the only thing I'm seeing in Lens (installed the logs sample data, no other index patterns around):
Screenshot 2020-10-22 at 15 24 59

It seems like the logic we put in place to remap the field formats to a serialized format don't always work and need a safeguard (x-pack/plugins/lens/public/indexpattern_datasource/loader.ts): #80132 (files)

Apparently formatters into indexPatterns can be either instanciated or already serialized. I've added a serialized version of one formatter in the test to always keep it tracked in the future, and also handle both scenarios.

@flash1293
Copy link
Contributor

flash1293 commented Oct 22, 2020

Played around with this and I think it's working fine. Would really appreciate another look from @wylieconlon though (as I'm only superficially familiar with that part of Lens).

I did notice a weird behavior, but I'm not sure whether it's related to this PR, so it's fine fixing it separately (noting it here to make sure it isn't):

When switching from explicit ranges to auto histogram, the local formatting is reset (in this example it's jumping from bytes to default) - maybe there is a good reason, but it seemed surprising to me:
lost_format

The code would benefit from moving some logic into the datasource, but as discussed we can handle this separately.

@dej611
Copy link
Contributor Author

dej611 commented Oct 22, 2020

I see your point.
The reset behaviour is for consistency with the decision ( made in #76121 ) to reset all the configuration when moving from one mode to another, but this case I guess it's not strictly related to that.

@flash1293
Copy link
Contributor

I see, let’s discuss this separately as it’s not related to the changes made here

Copy link
Contributor

@wylieconlon wylieconlon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of leaving a review with a lot of comments, can you check out my PR against this branch? dej611#2

Basically I've made several change that I think are nicer:

  1. Move the format_column function into the datasource
  2. Simplified the formatting arguments
  3. Renamed the formatted arguments to consistently use format to refer to the number formatter and parentFormat to refer to the ranges formatter

@dej611
Copy link
Contributor Author

dej611 commented Oct 26, 2020

Instead of leaving a review with a lot of comments, can you check out my PR against this branch? dej611#2

Basically I've made several change that I think are nicer:

  1. Move the format_column function into the datasource
  2. Simplified the formatting arguments
  3. Renamed the formatted arguments to consistently use format to refer to the number formatter and parentFormat to refer to the ranges formatter

That looks good. I had a check on it and it seems to better encapsulate the logic with streamlined flow for complex format scenarios.

Organize the formatting differently
@dej611
Copy link
Contributor Author

dej611 commented Oct 26, 2020

@elasticmachine merge upstream

@dej611 dej611 requested a review from a team as a code owner October 27, 2020 08:29
@@ -35,6 +36,7 @@ export class IndexPatternDatasource {
editorFrame.registerDatasource(async () => {
const { getIndexPatternDatasource, renameColumns } = await import('../async_services');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the new setup of making this an implementation detail of the datasource - can we move the formatColumn import into the async_services so it's loaded async?

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

async chunks size

id before after diff
lens 1.1MB 1.1MB +5.6KB

page load bundle size

id before after diff
data 1.1MB 1.1MB +485.0B
lens 63.5KB 61.1KB -2.4KB
total -1.9KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the bundle limit increase was removed 👍 I dig it!

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works as expected, LGTM 👍

@dej611 dej611 merged commit 8f92de8 into elastic:master Oct 27, 2020
@dej611 dej611 deleted the feature/range-alternative-formatter branch October 27, 2020 17:08
gmmorris added a commit to gmmorris/kibana that referenced this pull request Oct 27, 2020
* master: (87 commits)
  [Actions] Adding `hasAuth` to Webhook Configuration to avoid confusing UX (elastic#81778)
  [i18n] add get_kibana_translation_paths tests (elastic#81624)
  [UX] Fix search term reset from url (elastic#81654)
  [Lens] Improved range formatter (elastic#80132)
  [Resolver] `SideEffectContext` changes, remove `@testing-library` uses (elastic#81077)
  [Time to Visualize] Update Library Text with Call to Action (elastic#81667)
  [docs] Resolving failed Kibana upgrade migrations (elastic#80999)
  [ftr/menuToggle] provide helper for enhanced menu toggle handling (elastic#81709)
  [Task Manager] adds basic observability into Task Manager's runtime operations (elastic#77868)
  Doc changes for stack management and grouped feature privileges (elastic#80486)
  Added functional test for alerts list filters by status, alert type and action type. Did a code refactoring and splitting for alerts tests. (elastic#81422)
  [Security Solution][Endpoint][Admin] Malware Protections Notify User Version (elastic#81415)
  Revert "[Actions] Adding `hasAuth` to Webhook Configuration to avoid confusing UX (elastic#81390)"
  [Maps] Use default format when proxying EMS-files (elastic#79760)
  [Discover] Deangularize context.html (elastic#81442)
  Use the displayName property in default editor (elastic#73311)
  adds bug label to Bug report for Security Solution template (elastic#81643)
  [ML] Transforms: Remove index field limitation for custom query. (elastic#81467)
  [Actions] Adding `hasAuth` to Webhook Configuration to avoid confusing UX (elastic#81390)
  [Task Manager] Mark task as failed if maxAttempts has been met. (elastic#80681)
  ...
dej611 added a commit to dej611/kibana that referenced this pull request Oct 27, 2020
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Wylie Conlon <wylieconlon@gmail.com>
Co-authored-by: Joe Reuter <johannes.reuter@elastic.co>
dej611 added a commit that referenced this pull request Oct 28, 2020
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Wylie Conlon <wylieconlon@gmail.com>
Co-authored-by: Joe Reuter <johannes.reuter@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Lens release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Improve range formatting
9 participants