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] Add collapse fn to table and xy chart #131748

Merged
merged 10 commits into from
May 16, 2022

Conversation

flash1293
Copy link
Contributor

@flash1293 flash1293 commented May 6, 2022

Fixes #94619

This PR adds the ability to collapse the xy breakdown dimension or an arbitrary "row" in the table visualization.

Screenshot 2022-05-06 at 17 59 04

Screenshot 2022-05-06 at 17 58 59

If selected, the chart behaves as if the dimension doesn't exist, and its values are aggregated according to the selected function.

It would be theoretically possible to add a similar functionality to the partition chart but I don't see a large value for that because there are no common use cases where this would be necessary (and it's also no gap w.r.t. TSVB). Because of this IMHO such a feature would be more confusing than helpful for partition charts and it's better to push some possible exotic use cases into the text based languages.

Technical details

The collapse function is a separate expression function lens_collapse which takes a datatable and a list of columns to split by (the buckets) and a list of columns to collapse (the metrics) by a given function fn. All other columns are removed in the process. It's similar to overall_metric with the difference that the result isn't written to a separate column but instead replaces the existing metric column values and only produces a single row per group.

It is called by the supporting visualization before the table is passed to the actual visualization function). In case a collapse function is selected on a dimension, it is hidden for the visualization function.

Note: This PR overlaps with #131699 as it needs to migrate the datatable visualization off multi table to make it work.

@flash1293 flash1293 added release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens backport:skip This commit does not require backporting v8.3.0 labels May 6, 2022
@flash1293 flash1293 marked this pull request as ready for review May 10, 2022 15:21
@flash1293 flash1293 requested a review from a team as a code owner May 10, 2022 15:21
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors)

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

Joe this looks and it works great!
I only have a UX question, it is not so important, but I just want to discuss it

I have a chart like this (collapsed by sum)
image

I see that the breakdown has this invisible icon and no palette which makes sense. But the color of my chart is defined by the palette. As a user, my first instinct was to go to the metric and change the color of my series from there but I can't. I can only change the color by changing the palette and I dont have a lot of options here as the first palette color is automatically selected.

I find a bit confusing but maybe it is just me. Wdyt?

@flash1293
Copy link
Contributor Author

I find a bit confusing but maybe it is just me. Wdyt

No, you are right, it should be possible to change the color like as for a regular metric, gonna adjust that.

@flash1293
Copy link
Contributor Author

@stratoula Fixed, the color pickers is now enabled if the breakdown dimension is collapsed.

Copy link
Contributor

@stratoula stratoula 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 Joe! This looks great 👏 LGTM!

The 5KB increase is due to the new expression right?

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
lens 764 767 +3

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
lens 451 452 +1

Async chunks

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

id before after diff
lens 1.1MB 1.1MB -4.6KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
lens 27.5KB 32.5KB +5.0KB
Unknown metric groups

API count

id before after diff
lens 526 527 +1

async chunk count

id before after diff
lens 10 11 +1

History

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

@ghudgins
Copy link

changes LGTM

@flash1293 flash1293 merged commit 81dce64 into elastic:main May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Lens release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Summarize a break down by (collapse bucket column)
5 participants