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 median operation #79453

Merged
merged 4 commits into from
Oct 16, 2020
Merged

[Lens] Add median operation #79453

merged 4 commits into from
Oct 16, 2020

Conversation

flash1293
Copy link
Contributor

@flash1293 flash1293 commented Oct 5, 2020

Fixes #74889

This PR adds a median operation similar to min and max to Lens.

Screenshot 2020-10-05 at 15 00 22

As this makes the number of operations odd for the y axis dimension group of the xy chart, I had to add some logic to add a dummy item in there (https://github.com/elastic/kibana/pull/79453/files#diff-5c0e534b2b688cca97714cf5500805b4R268-R270) - otherwise the css column layout would break within an operation item like this:
Screenshot 2020-10-05 at 15 04 22

I tried to prevent this on the CSS level (-webkit-column-break-inside: avoid) but didn't have any luck. @cchaos maybe you know a better option.

@flash1293 flash1293 marked this pull request as ready for review October 5, 2020 14:37
@flash1293 flash1293 requested a review from a team October 5, 2020 14:37
@flash1293 flash1293 added the Team:Visualizations Visualization editors, elastic-charts and infrastructure label Oct 5, 2020
@elasticmachine
Copy link
Contributor

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

@mbondyra
Copy link
Contributor

mbondyra commented Oct 5, 2020

Just like we discussed, one of the options would be to overwrite eui display:flex for EuiGroupListItems either with display:inline-flex or display: block:

.lnsIndexPatternDimensionEditor__operation {
  display: inline-flex;
}

Maybe Caroline know better tricks here.

Apart from that, I love how simple this PR is 👏

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.

There is a bug when using the Median as the sort order for the Terms aggregation, and it causes the visualization to throw an Elasticsearch error:

reason: "Invalid aggregation order path [5910a8af-b666-4c2c-84d2-8c9560b1628e]. When ordering on a multi-value metrics aggregation a metric name must be specified."
type: "aggregation_execution_exception"

I'm fine with this workaround to the column spacing. The root cause of the issue appears to be the vertical centering logic in EuiListGroupItem, so without a PR to EUI this looks like one of the cleaner solutions.

There

@flash1293
Copy link
Contributor Author

flash1293 commented Oct 6, 2020

Great catch @wylieconlon - I checked and this is a shortcoming of the AggType framework, Elasticsearch can do this just fine, the path to the order agg just needs a .50 suffix (

). I will attempt to fix that in the AggType.

@mbondyra Seems like this PR is about to get a little more complex, sorry ;-)

listItems={
// add a padding item containing a non breakable space if the number of operations is not even
// otherwise the column layout will break within an element
sideNavItems.length % 2 === 1 ? [...sideNavItems, { label: '\u00a0' }] : sideNavItems
Copy link
Contributor

Choose a reason for hiding this comment

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

This solution is fine with me so long as it doesn't create an item that behaves inertactable with a blank label.

@flash1293
Copy link
Contributor Author

I set up a separate PR to fix the median ordering here: #79839 This PR is blocked till then.

@flash1293
Copy link
Contributor Author

@elasticmachine merge upstream

@flash1293 flash1293 requested a review from wylieconlon October 14, 2020 11:05
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.

Tested and LGTM!

@flash1293
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

async chunks size

id before after diff
lens 1.0MB 1.0MB +475.0B

History

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

@flash1293 flash1293 merged commit 52b35f3 into elastic:master Oct 16, 2020
flash1293 added a commit to flash1293/kibana that referenced this pull request Oct 16, 2020
flash1293 added a commit that referenced this pull request Oct 16, 2020
gmmorris added a commit to gmmorris/kibana that referenced this pull request Oct 19, 2020
* master: (51 commits)
  [Discover] Unskip flaky test (elastic#80670)
  Fix security solution template label (elastic#80754)
  [Ingest]: ignore 404, check if there are transforms in results. (elastic#80721)
  Moving loader to logo in header, add a slight 250ms pause (elastic#78879)
  [Security Solution][Cases] Fix bug with case connectors (elastic#80642)
  Update known-plugins.asciidoc (elastic#75388)
  [Lens] Add median operation (elastic#79453)
  Fix navigateToApp logic when navigating to the current app. (elastic#80809)
  [Visualizations] Fix bad color mapping with multiple split series (elastic#80801)
  [ILM] Add esErrorHandler for the new es js client (elastic#80302)
  Fix codeowners (elastic#80826)
  skip flaky suite (elastic#79463)
  [Timelion] Remove kui usage (elastic#80287)
  [Ingest Manager] add skipIfNoDockerRegistry to package_install_complete test (elastic#80779)
  [Alerting UI] Disable "Save" button for Alerts with broken Connectors (elastic#80579)
  Allow the default space to be accessed via `/s/default` (elastic#77109)
  Add script to identify plugin dependencies for TS project references migration (elastic#80463)
  [Search] Client side session service (elastic#76889)
  feat: 🎸 add separator for different context menu groups (elastic#80498)
  Lazy load reporting (elastic#80492)
  ...
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] Support median as metric aggregation
6 participants