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] Client side sorting for categorical data #121558

Closed
wants to merge 5 commits into from

Conversation

dej611
Copy link
Contributor

@dej611 dej611 commented Dec 17, 2021

Summary

Ref: #86184

This PR explores the potentiality of the client side sorting of categorical data for the visualizations.

Some assumptions made on the current implementation:

  • elastic-charts do not provide many sorting predicate handlers, therefore most of the time the sort override is performed at the table level, and indirectly picked up by the charts library.
  • empty and Other values are always sorted at the end (Other before, (empty) last) for alphabetical and "Terms list" mode.
    • It is possible to override this behaviour using the Terms list option which let the user specify specific priorities
  • XY charts + Heatmap do support sorting at the moment
    • X axis is considered the "main" sorting dimension, while the break down(XY)/Y axis(Heatmap) is considered nested. When a nested dimension has a sorting override but not the main one, then a warning will be shown, as there's no way to guarantee a stable sorting for the main dimension.
    • ❌ Sometimes it is not possible to enforce a nested sorting override as there's no way manipulating the table to force the chart
    • ❌ Metric over stacked charts may result in unexpected rendering as the table is unaware of the visualization type
  • Mosaic is the only partition chart that supports the sortable option
    • Only the first Group by dimension will have the sorting option as it is not possible to set an internal order
  • Datatable support the sortable option, but not on the Column group.
  • Legends does not have yet a sortable control yet.
  • Ranges are not yet sortable (it requires some more special handling )

Few extras in this PR:

  • Metrics can be hidden now in XY Chart and Heatmap (it requires 2+ metrics)
    • This makes it possible to sort by a metric which is not visible
  • It has been made a generic "StackedPanel" component for the flyout, used by the PalettePanel and provides the same functionality of the stacked Palette UI

There are probably some bugs which I haven't spotted yet, but will try to address it next time.

Basic UI:

Screenshot 2021-12-17 at 18 59 07

The sorting direction is shown when a sorting override is chosen, other than None:

Screenshot 2021-12-17 at 18 59 25

List of available sorting overrides with multiple metrics:
Screenshot 2021-12-17 at 19 03 40

Choosing "List of terms" enables the "Edit list" button
Screenshot 2021-12-17 at 19 05 21

Use cases:

Scenario GIF (click to zoom)
✅ Metric sort Screenshot 2021-12-17 at 19 01 02
✅ Metric sort (percentile, hidden metric) Screenshot 2021-12-17 at 19 02 17
✅ Metric sort (formula) Screenshot 2021-12-17 at 19 03 31
✅ Explicit sort Screenshot 2021-12-17 at 19 05 12
⚠️ Warning about "partial" sorting for break down Screenshot 2021-12-20 at 10 57 53
⚠️ Warning about "partial" sorting for Heatmap vertical dimension Screenshot 2021-12-20 at 10 57 07

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@dej611
Copy link
Contributor Author

dej611 commented Jan 10, 2022

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

kibana-ci commented Jan 10, 2022

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #5 / heatmap #getConfiguration resolves configuration from complete state and available data
  • [job] [logs] Jest Tests #5 / heatmap #getConfiguration resolves configuration from partial state
  • [job] [logs] Jest Tests #5 / heatmap #getConfiguration resolves configuration when there's no access to active data in frame
  • [job] [logs] Jest Tests #5 / heatmap #getWarningMessages should not return warning messages when the data table is empty
  • [job] [logs] Jest Tests #5 / IndexPattern Data Source #toExpression references should topologically sort references
  • [job] [logs] Jest Tests #5 / IndexPattern Data Source #toExpression should create a table when there is a formula without aggs
  • [job] [logs] Jest Tests #5 / IndexPattern Data Source #toExpression should generate an expression for an aggregated query

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
lens 710 720 +10

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 246 247 +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 1021.1KB 1.0MB +13.5KB

Page load bundle

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

id before after diff
lens 41.0KB 41.4KB +487.0B
Unknown metric groups

API count

id before after diff
lens 263 264 +1

async chunk count

id before after diff
lens 9 10 +1

History

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

@legrego legrego closed this Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants