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] Provide single-value functions to show the "Last" value of some field #83437

Merged
merged 34 commits into from
Dec 2, 2020

Conversation

mbondyra
Copy link
Contributor

@mbondyra mbondyra commented Nov 16, 2020

Summary

Fixes #55895 and #83655

This PR adds new type of metric operation last value – it has the same behavior as Visualize 'top_hits' but with some limitations prioritizing user experience. Here's the behavior description:

  • only one last value is displayed,
  • value can be only sorted by time fields (so it's the last value in time). If there's no timefields in the index pattern, operation cannot be used
  • for numerical fields, the value can be formatted
  • charts (xy and pie) can only accept numerical values. Metric and datatable accept all types.
  • operation cannot be used on rollup index patterns
  • operation is never default when fields are dragged to droppable areas

Here's the example screenshots:

image

When there's no timefield:
image

When the time field was removed from index and there's invalid reference:
image
I changed the messaging in error handling – now we don't use names of fields, but the label of column. I think it's a change for better because it's much easier for the user to identify the place where the reference has to be fixed.

With numeric arrays for metric on pie (or y-accessors for xy chart)
image

Checklist

Delete any items that are not applicable to this PR.

@mbondyra mbondyra added release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 Feature:Lens v7.11.0 labels Nov 16, 2020
@mbondyra
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@elastic elastic deleted a comment from apmmachine Nov 18, 2020
Copy link
Contributor

@myasonik myasonik left a comment

Choose a reason for hiding this comment

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

Just a minor a11y question but want an actual designer to take a look at my Sass comment but otherwise LGTM

@dej611
Copy link
Contributor

dej611 commented Nov 19, 2020

Code looks good 👍 , just two minor changes proposed. Will test locally next 🚀

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.

As this is a new place to store a field reference, we should

  • add it to the validation logic in x-pack/plugins/lens/public/indexpattern_datasource/utils.ts#getInvalidLayers
  • Handle missing fields in the UI similar to how it's done for invalid sourceFields

@mbondyra
Copy link
Contributor Author

@elasticmachine merge upstream

@mbondyra
Copy link
Contributor Author

@elasticmachine merge upstream

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.

This looks great! Left some minor comments

…st_value

# Conflicts:
#	x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts
@flash1293
Copy link
Contributor

@elasticmachine merge upstream

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 LGTM

Copy link
Contributor

@MichaelMarcialis MichaelMarcialis left a comment

Choose a reason for hiding this comment

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

This is looking great, @mbondyra! Left a few comments for your review.

…t_value

# Conflicts:
#	x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/count.tsx
#	x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts
#	x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/metrics.tsx
Copy link
Contributor

@MichaelMarcialis MichaelMarcialis left a comment

Choose a reason for hiding this comment

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

Thank you for making those previous changes. I've left a few more minor stylistic change requests/comments, but I'll approve now so as not to hold you up any further.

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.

The functionality is working, including error states- most of my comments are about the form design. I'm hoping we can make a more user-friendly form design like we talked about, by removing the words "sort order" from the UI.

})}
isInvalid={isSortFieldInvalid}
>
<EuiComboBox
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't blur this combobox on click outside. Is it configured differently than usual? Something seems wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I cannot reproduce it. Can you send me a video or let's talk during sync.

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.

I haven't re-tested it, but I'm approving now that sort order is removed. The form UI issue is something I'm not just seeing on your PR, so let's deal with it separately.

…t_value

# Conflicts:
#	x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.tsx
@mbondyra mbondyra merged commit 6900ce2 into elastic:master Dec 2, 2020
@mbondyra mbondyra deleted the lens/last_value branch December 2, 2020 18:56
mbondyra added a commit to mbondyra/kibana that referenced this pull request Dec 2, 2020
mbondyra added a commit that referenced this pull request Dec 3, 2020
@flash1293 flash1293 changed the title [Lens] Provide single-value functions to show the "First" or "Last" value of some field [Lens] Provide single-value functions to show the "First" value of some field Dec 4, 2020
@flash1293 flash1293 changed the title [Lens] Provide single-value functions to show the "First" value of some field [Lens] Provide single-value functions to show the "Last" value of some field Dec 4, 2020
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
lens 447 458 +11

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 972.6KB 995.5KB +22.9KB

Distributable file count

id before after diff
default 43205 43206 +1

History

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

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] Provide single-value functions to show the "First" or "Last" value of some field
10 participants