-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Pie] Loads the no results screen if all slices have zero value #111931
Conversation
x-pack/plugins/lens/public/pie_visualization/render_helpers.test.ts
Outdated
Show resolved
Hide resolved
Just wanted to mention here too the result of our chat with @stratoula: while there's no record of the driver for adding an epsilon in the very 1st commit of the original Lens PR, it may have been motivated by a desire to show zero valued legend items, which, in the absence of other arguments, is not the best default (there can be a high number of zero-valued items, all with color assignment, which don't show up as slices, so it's generally not valuable or sensible for the user). So I think the better baseline behavior is to not have legends for zero valued items, unless a real driver becomes known. Product needs to know about this facet, and if there's significant user demand, it's feasible for Kibana to add a toggle for showing zero values, as well as Charts to optionally enable zero-valued items in the legend without a Kibana-side EPSILON hack. |
This PR is actually two things:
Why to make this distinction, when both aspects are linked to the referred issue #111743? Because that issue only talks about a use case of all-zero slices, and neither the issue nor the PR discusses the more general circumstance of having some zero slices, which was the likely target of the EPSILON hack (and the special case of all zeros may not have been considered, or a check regressed since) |
Thanx @monfera for your comments :) Another thing that I decided to do in this PR is something that Lens already does. I try to find out if the metric has negative values and display the corresponding message |
src/plugins/vis_types/pie/public/components/visualization_noresults.tsx
Outdated
Show resolved
Hide resolved
Pinging @elastic/kibana-vis-editors (Team:VisEditors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a first code review. Left some minor comments.
src/plugins/vis_types/pie/public/components/visualization_noresults.tsx
Outdated
Show resolved
Hide resolved
} | ||
return Number.EPSILON; | ||
const value = d[metricColumn.id]; | ||
return Number.isFinite(value) && value >= 0 ? value : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it be Infinity/-Infinity
?
return Number.isFinite(value) && value >= 0 ? value : 0; | |
return Math.max(0, value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@monfera as you asked about this change wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the formula usage, it can be, right? count()/0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in formula that is handled by the expression system. Need to check that.
} | ||
return Number.EPSILON; | ||
const value = d[metricColumn.id]; | ||
return Number.isFinite(value) && value >= 0 ? value : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more feedback from testing it:
- this more an edge case, but when sizing pie slices by
Top Hit
+Aggregate with
any function for negative or all zero values it shows an empty workspace:
Underneath the server is returning undefined
values for each row value:
The legacy version didn't work well either, showing a 0% label:
- In Lens the negative message is way too long for the suggestions, perhaps it can be improved also for the main workspace:
@elasticmachine merge upstream |
For the error messages, I'd just remove 'try a different visualization type'. Suggestions kind of show it anyway. CC @MichaelMarcialis I tested Lens only so far with different configurations and all work fine.
|
Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com>
Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested Lens thoroughly and Pie chart a bit less, but still trying to think about all the edgecases. Code LGTM 👌🏼
💚 Build SucceededMetrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
…tic#111931) * [Pie] Loads the no results screen if all slices have zero value * Add a functional test * Apply PR changes * Display no results component if the chart metric has negative values * Nits * Apply some of the PR comments * Change the negative values text * Update src/plugins/vis_types/pie/public/pie_component.test.tsx Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com> * Update src/plugins/vis_types/pie/public/pie_component.test.tsx Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com>
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
) (#112250) * [Pie] Loads the no results screen if all slices have zero value * Add a functional test * Apply PR changes * Display no results component if the chart metric has negative values * Nits * Apply some of the PR comments * Change the negative values text * Update src/plugins/vis_types/pie/public/pie_component.test.tsx Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com> * Update src/plugins/vis_types/pie/public/pie_component.test.tsx Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com> Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co> Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com>
Summary
Fixes #111743
This PR fixes a problem that occurs in the legacy pie (es-charts implementation). What happens here is that when we have data with zero values it fallbacks to Number.EPSILON. This is an actual value and es-charts renders it causing this weird behavior. I changed it to fallback to zero. When the slice value is zero nothing is rendered from the es-charts side. In order to not render a blank component I added a
no results component
. So if I find that all the metric values are zero then I render this component.I also investigated how Lens behaves. I can't break it. Lens works correctly for zero values. But as I think that this fallback to epsilon doesn't make sense I also changed a bit the
getSliceValue
to return zero as a fallback. It seems that nothing breaks with this change.Checklist