-
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
[Lens] Allow palette configuration for metric #116170
Conversation
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
I gave this PR a look (from the commit ~18 hours ago). here's my feedback:
|
Fixed the two raised issues @ghudgins . |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
|
||
// NOTE: Cardinality and Sum never receives "null" as value, but always 0, even for empty dataset. | ||
// Mind falsy values here as 0! | ||
const shouldShowResults = row[accessor] != null; | ||
if (!shouldShowResults) { | ||
if (rawValue == null) { |
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.
const rawValue = row[accessor];
// NOTE: Cardinality and Sum never receives "null" as value, but always 0, even for empty dataset.
// Mind falsy values here as 0!
if (typeof rawValue !== 'number') {
return getEmptyState();
}
This would allow us to avoid type assertion, WDYT?
x-pack/plugins/lens/public/metric_visualization/dimension_editor.tsx
Outdated
Show resolved
Hide resolved
Nov-16-2021.09-46-58.mp4I think the initial value color for 0 might not be of a proper type (number instead of string) but not sure. |
From my understanding the uniform distribution should be always applied in #116422 . I hope most of the complex code here to disappear with the new UI and stops color structure. |
That's a good point. I think it is not necessary in this case, but I see why it can still make sense. No strong opinion here. cc @ghudgins @flash1293 what do you think about it? |
In favor of showing the palette indicator to stay consistent - if a dimension is doing coloring, it should be shown in the UI |
Addressed all issues reported here:
Operating the fix on the shared area, this should also fix #117512
And all the other code review feedbacks 👍 |
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.
Code LGTM, tested and all works good 👍🏼
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
* ✨ Metrics have colors * 🏷️ Fix type issues * 🐛 Fix dimension removal bug * 🐛 Fix initial stops computation * 🐛 Fix various bugs + unit tests * ✅ Add functional tests * 🐛 Fix the reverse bug and failing tests * bug: Fix custom stops issue with attached tests * 🐛 Reintroduced continuity logic and fixed 2 stops problem * 🐛 Fix palette display + default palette behaviour * 🐛 Fix edge case when switching to default palettes * 💄 Display custom stop when available or uniform palette for defaults * 💄 Integrated feedback * commit using @elastic.co * commit using @elastic.co * 📸 Updated snapshots * Update x-pack/plugins/lens/public/metric_visualization/expression.scss Co-authored-by: Michael Marcialis <michael@marcial.is> * 👌 integrated feedback * 🐛 Revert codeline change * :feature: Add palette display on field dimension * ✅ Fix functional test Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Michael Marcialis <michael@marcial.is>
* ✨ Metrics have colors * 🏷️ Fix type issues * 🐛 Fix dimension removal bug * 🐛 Fix initial stops computation * 🐛 Fix various bugs + unit tests * ✅ Add functional tests * 🐛 Fix the reverse bug and failing tests * bug: Fix custom stops issue with attached tests * 🐛 Reintroduced continuity logic and fixed 2 stops problem * 🐛 Fix palette display + default palette behaviour * 🐛 Fix edge case when switching to default palettes * 💄 Display custom stop when available or uniform palette for defaults * 💄 Integrated feedback * commit using @elastic.co * commit using @elastic.co * 📸 Updated snapshots * Update x-pack/plugins/lens/public/metric_visualization/expression.scss Co-authored-by: Michael Marcialis <michael@marcial.is> * 👌 integrated feedback * 🐛 Revert codeline change * :feature: Add palette display on field dimension * ✅ Fix functional test Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Michael Marcialis <michael@marcial.is>
* ✨ Metrics have colors * 🏷️ Fix type issues * 🐛 Fix dimension removal bug * 🐛 Fix initial stops computation * 🐛 Fix various bugs + unit tests * ✅ Add functional tests * 🐛 Fix the reverse bug and failing tests * bug: Fix custom stops issue with attached tests * 🐛 Reintroduced continuity logic and fixed 2 stops problem * 🐛 Fix palette display + default palette behaviour * 🐛 Fix edge case when switching to default palettes * 💄 Display custom stop when available or uniform palette for defaults * 💄 Integrated feedback * commit using @elastic.co * commit using @elastic.co * 📸 Updated snapshots * Update x-pack/plugins/lens/public/metric_visualization/expression.scss Co-authored-by: Michael Marcialis <michael@marcial.is> * 👌 integrated feedback * 🐛 Revert codeline change * :feature: Add palette display on field dimension * ✅ Fix functional test Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Michael Marcialis <michael@marcial.is>
* ✨ Metrics have colors * 🏷️ Fix type issues * 🐛 Fix dimension removal bug * 🐛 Fix initial stops computation * 🐛 Fix various bugs + unit tests * ✅ Add functional tests * 🐛 Fix the reverse bug and failing tests * bug: Fix custom stops issue with attached tests * 🐛 Reintroduced continuity logic and fixed 2 stops problem * 🐛 Fix palette display + default palette behaviour * 🐛 Fix edge case when switching to default palettes * 💄 Display custom stop when available or uniform palette for defaults * 💄 Integrated feedback * commit using @elastic.co * commit using @elastic.co * 📸 Updated snapshots * Update x-pack/plugins/lens/public/metric_visualization/expression.scss Co-authored-by: Michael Marcialis <michael@marcial.is> * 👌 integrated feedback * 🐛 Revert codeline change * :feature: Add palette display on field dimension * ✅ Fix functional test Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Michael Marcialis <michael@marcial.is>
* ✨ Metrics have colors * 🏷️ Fix type issues * 🐛 Fix dimension removal bug * 🐛 Fix initial stops computation * 🐛 Fix various bugs + unit tests * ✅ Add functional tests * 🐛 Fix the reverse bug and failing tests * bug: Fix custom stops issue with attached tests * 🐛 Reintroduced continuity logic and fixed 2 stops problem * 🐛 Fix palette display + default palette behaviour * 🐛 Fix edge case when switching to default palettes * 💄 Display custom stop when available or uniform palette for defaults * 💄 Integrated feedback * commit using @elastic.co * commit using @elastic.co * 📸 Updated snapshots * Update x-pack/plugins/lens/public/metric_visualization/expression.scss Co-authored-by: Michael Marcialis <michael@marcial.is> * 👌 integrated feedback * 🐛 Revert codeline change * :feature: Add palette display on field dimension * ✅ Fix functional test Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Michael Marcialis <michael@marcial.is>
Summary
Fixes #102035
This PR introduces the palette configurator to the metric visualization in Lens.
By default 3 stops are computed starting from the current metric.
When the metric value is 0 then a special [-50, 100] range is used (in order to not collapse the color stop values AND have 0 in the middle of the current range).
It also works for negative values correctly:
Custom stops are respected and override the default computation above when they exists.
metricVis
API update. #114116Write migrationno need, just fallback tonone
for old metricszero
valueChecklist
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:
For maintainers