-
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] Calculation operations #83789
Conversation
@wylieconlon This should build fine now |
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 is looking good! I left some stylistic comments, but this will definitely help develop the UI :)
...ins/lens/public/indexpattern_datasource/operations/definitions/calculations/counter_rate.tsx
Outdated
Show resolved
Hide resolved
...ins/lens/public/indexpattern_datasource/operations/definitions/calculations/counter_rate.tsx
Outdated
Show resolved
Hide resolved
...ins/lens/public/indexpattern_datasource/operations/definitions/calculations/counter_rate.tsx
Outdated
Show resolved
Hide resolved
...ins/lens/public/indexpattern_datasource/operations/definitions/calculations/counter_rate.tsx
Outdated
Show resolved
Hide resolved
...ugins/lens/public/indexpattern_datasource/operations/definitions/calculations/derivative.tsx
Outdated
Show resolved
Hide resolved
defaultMessage: 'Window size', | ||
})} | ||
display="columnCompressed" | ||
fullWidth |
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 form input is a good candidate for help text. I would like to explain some of the comments that we've written in the definition of the window, such as how it's trailing and how it deals with missing values.
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.
Do we have a design for that yet?
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.
There is no final design, but the idea that @MichaelMarcialis wants to explore is a popover-based help text. Tracking that effort here: #81780
} | ||
return [ | ||
i18n.translate('xpack.lens.indexPattern.calculations.dateHistogramErrorMessage', { | ||
defaultMessage: 'Needs a date histogram to work', |
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 this error message would be improved by adding more context, like Cumulative sum requires a date histogram to work. Choose a different function or add a date histogram.
This context might need to be passed in as an argument to the function
additionalArgs: Record<string, unknown[]> = {} | ||
): ExpressionFunctionAST[] { | ||
const currentColumn = (layer.columns[columnId] as unknown) as ReferenceBasedIndexPatternColumn; | ||
const buckets = layer.columnOrder.filter((colId) => layer.columns[colId].isBucketed); |
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.
Small tweak to the code style:
const buckets = layer.columnOrder.filter((colId) => layer.columns[colId].isBucketed); | |
const buckets = layer.columnOrder.filter((colId) => layer.columns[colId].isBucketed && layer.columns[colId].operationType !== 'date_histogram'); |
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.
That's not just a code style change - if there are two date histogram columns in the current table, this will prevent grouping by the second for applying the calculation, producing meaningless data.
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.
Good point, hadn't realized.
const dateColumnIndex = buckets.findIndex( | ||
(colId) => layer.columns[colId].operationType === 'date_histogram' | ||
)!; | ||
buckets.splice(dateColumnIndex, 1); |
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 dateColumnIndex = buckets.findIndex( | |
(colId) => layer.columns[colId].operationType === 'date_histogram' | |
)!; | |
buckets.splice(dateColumnIndex, 1); | |
const dateColumnIndex = layer.columnOrder.findIndex( | |
(colId) => layer.columns[colId].operationType === 'date_histogram' | |
)!; |
x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/utils.ts
Show resolved
Hide resolved
Thanks for the review @wylieconlon , I worked through the comments you didn't tackle yourself. There's a code style recommendation I don't get, could you check out that one? |
@elasticmachine merge upstream |
Pinging @elastic/kibana-app (Team:KibanaApp) |
@flash1293 I know this isn't related to this code directly, but it looks like the |
|
||
const ofName = (name?: string) => { | ||
return i18n.translate('xpack.lens.indexPattern.cumulativeSumOf', { | ||
defaultMessage: 'Cumulative sum rate of {name}', |
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.
Are we expecting this to be Cumulative sum of <field>
? It's currently Cumulative sum of <reference label>
?
This is part of my reference UI work, so you might not need to make a change. I'm regenerating the default labels whenever you modify an operation.
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.
hm, good point, I'm not sure actually. Let's keep that for now and see whether we want to keep it once transition/UI is in place
@wylieconlon Registered counter rate as part of this PR |
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
# Conflicts: # x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.test.ts # x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.ts
Based on #83603
This PR adds some real implementations for reference-based operations:
cc @wylieconlon