-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] New summary row feature for datatable #101075
Conversation
This looks pretty good! For transposed columns, space per column gets tight quickly (we have the same issue with the headers). I'm fine with solving this along with the headers though. Some tools seem to move the summary label to the non-transposed column and only the show the value per transposed column, but it would probably not work well in all cases. I think avoiding summary rows for string columns in the first version is a good call as it adds quite a bit of complexity and seems like an edge case. Let's keep it simple as long as we can. Can we rename |
@elasticmachine merge upstream |
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.
This looks almost good to me, just some uncertainty around the handling of array values. It looks like right now we don't treat the current column as "summarizeable" if there are array values, but it seems like it's a small addition to do so and remove an element of surprise ("why is the summary row disappearing if I change my time range"?). If this is complex to do I think we can also leave it like it works right now.
@@ -358,6 +361,8 @@ export const getDatatableVisualization = ({ | |||
reverse: false, // managed at UI level | |||
}; | |||
|
|||
const HasNoSummaryRow = column.summaryRow == null || column.summaryRow === 'none'; |
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.
nit: hasNoSummaryRow
isNumeric && | ||
currentData?.rows.every(({ [accessor]: value }) => typeof value === 'number' || value == null); | ||
|
||
return { isNumeric, hasAllNumericValues: hasFieldNumericValues }; |
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.
Nit: This is causing the summary row to disappear completely from table and config flyout if there is an array value (which can happen because of last value). Did this happen on purpose? Or should we treat each array value as a separate value in terms of summary calculation?
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.
Maybe this function could workout whether numeric arrays are available as well and report that.
I planned to use this function also for other feature checks as well where non-numeric columns may lead to issues.
On the other hand, considering numeric arrays as valid numeric values may be a good solution. In this case I'd probably show a warning about the presence of array values and compute them as valid values.
@elasticmachine merge upstream |
@dej611 Did you miss this comment? |
Yes I saw it, but when attempting to do it I realised it may be non so intuitive to compute the summaries on arrays. |
Can you explain why? cc @ghudgins - I think it's too scary of a tool for the situation. |
Pinging @elastic/kibana-app (Team:KibanaApp) |
@elasticmachine merge upstream |
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.
Seems like there is some leftover logic which is causing a bug
const value = row[accessor]; | ||
hasFieldOnlyNumberValues = hasFieldOnlyNumberValues && isValidNumber(value); | ||
hasFieldNumericValues = | ||
(hasFieldNumericValues && hasFieldOnlyNumberValues) || |
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.
This logic is not correct - if there are arrays in the current column and the last row doesn't have a value, hasFieldNumericValues
will become false: (first FEMALE
column doesn't have a summary because the last row is undefined)
Also I found this logic extremely hard to follow and it seems like it's not used anywhere - hasNumberValues
is never accessed and it seems like this function is only returning a complex object because of this and can be simplified to this for all consumers:
export function isNumericField(currentData: Datatable | undefined, accessor: string) {
return currentData?.rows.every(row => {
const val = row[accessor];
return isValidNumber(val) || Array.isArray(val) && val.every(isValidNumber);
});
}
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.
The specific distinction in this function was propaedeutical for more than this specific case, that's the reason it is in the root folder.
I've built on top of this PR a fix for dynamic coloring using this utility.
I've reworked it a bit to fix this specific issue and speed up the computation in case it's not valid. In case you think it's best to have something lighter and more feature specific I can rewrite it as well.
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.
If we don't know whether we are ever going to need it, please let's remove it for now. I only found this issue by chance because the data I was testing with had that specific case.
Seems like some tests have to be adjusted for combo box |
const summaryValue = computeFinalValue(columnArgs.summaryRow, columnArgs.columnId, table.rows); | ||
// ignore the coluymn formatter for the count case | ||
if (columnArgs.summaryRow === 'count') { | ||
return summaryValue; |
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.
options={getSummaryRowOptions()} | ||
selectedOptions={[ | ||
{ | ||
label: fallbackSummaryLabel, |
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.
summaryRowValue: config.summaryRowValue, | ||
...getFinalSummaryConfiguration(config.columnId, config, firstTable), | ||
})) | ||
.filter(({ summaryRow }) => summaryRow !== 'none'); |
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.
💚 Build SucceededMetrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
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.
LGTM, great work!
* ✨ New summary row feature for datatable * ✨ Allow empty strings behind flag + tests * 🐛 Address the transition problem + refactor * ✅ Add some unit tests * ✅ Add first functional tests * 👌 first feedback addressed * ✨ Make it handle numeric array values * 📝 Improved message * ✅ Fix functional test * 🔥 Remove warning message for last value * 🚨 Remove unused import * 🐛 Fix a bug with last value * 👌 Integrated feedback * 💄 Migrated to combobox * ✅ Fix unit tests + restore right data-test-id * 🏷️ Fix type issue * 👌 Address all issues reported Co-authored-by: Kibana Machine <[email protected]>
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
* ✨ New summary row feature for datatable * ✨ Allow empty strings behind flag + tests * 🐛 Address the transition problem + refactor * ✅ Add some unit tests * ✅ Add first functional tests * 👌 first feedback addressed * ✨ Make it handle numeric array values * 📝 Improved message * ✅ Fix functional test * 🔥 Remove warning message for last value * 🚨 Remove unused import * 🐛 Fix a bug with last value * 👌 Integrated feedback * 💄 Migrated to combobox * ✅ Fix unit tests + restore right data-test-id * 🏷️ Fix type issue * 👌 Address all issues reported Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Marco Liberati <[email protected]>
* master: clarify which parts of TM are experimental (elastic#101757) Add sh scripts with _bulk_action route usage examples (elastic#101736) [Uptime] Only register route in side nav if uptime show capability is true (elastic#101709) Use KIBANA_DOCS in doc link service (elastic#101667) [Alerting][Event log] Persisting duration information for active alerts in event log (elastic#101387) Address design issues in Discover/Graph (elastic#101584) Optimize performance for document table (elastic#101715) Change file data visualizer links to point to new location in home application (elastic#101393) [Fleet] Tighten policy permissions, take II (elastic#97366) [ML] Add debounce to the severity control update (elastic#101581) [Fleet] Fix routing issues with `getPath` and `history.push` (elastic#101658) [APM] Add link-to/transaction route (elastic#101731) [Index Patterns] Runtime fields CRUD REST API (elastic#101164) [ILM] Refactor types and fix missing aria labels (elastic#101518) [Lens] New summary row feature for datatable (elastic#101075) Blocks save event filter with a white space name (elastic#101599) Improve security server types (elastic#101661) [APM] Replace side nav with tabs on Settings page (elastic#101460) [APM] Only register items in side nav if user has permissions to see app (elastic#101707) [Security solution][Endpoint] Add back button when to the event filters list (elastic#101280)
Summary
Fixes #84558
This PR adds the summary row feature to the Lens datatable visualization.
List of features:
sum
,average
,count
,minimum
,maximum
for numeric valuescount
uses the default numeric formatterLens editor:
Transposed columns:
Last value is not supported yet
Open questions:
Last value
(and similarlyIntervals
custom ranges)Initially I've also added the
count
+unique_count
for string columns, but had to remove it due to issues with dimension transitions.I think there's some potential in having them, but I guess that for V1 is ok to not have it.
In terms of implementation detail, I think, the visualization ought to know a bit more meta information about the dimension update, in order to reset the right options, or it is pretty easy to land on inconsistent states. This was the issue I faced when transitioning from one operation to another.
What is
Count
counting?Currently
count
takes into account only rows with actual data, ignoring empty rows. Is that ok?Checklist
Delete any items that are not applicable to this PR.
For maintainers