-
Notifications
You must be signed in to change notification settings - Fork 8k
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
[ML][Embeddables Rebuild] Migrate Anomaly Chart #183456
Conversation
…bed-migrate # Conflicts: # x-pack/plugins/ml/public/ui_actions/edit_single_metric_viewer_panel_action.tsx # x-pack/plugins/ml/public/ui_actions/index.ts
/ci |
/ci |
/ci |
7d16ae2
to
5aef100
Compare
Thanks @peteharverson and @alvarezmelissa87 for testing. I've fixed the 'unsaved changes', chart text overflowing/cutting off, and timeout warning in the data report in the latest changes. Screen.Recording.2024-05-21.at.14.32.53.mov |
@@ -62,7 +62,9 @@ export const ExplorerAnomaliesContainer: FC<ExplorerAnomaliesContainerProps> = ( | |||
timeRange, | |||
}) => { | |||
return ( | |||
<> | |||
// TODO: Remove data-shared-item and data-rendering-count as part of https://github.com/elastic/kibana/issues/179376 |
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.
Note for reviewers: Leaving this here as todo for future when referenced Kibana issue is closed
const factory: ReactEmbeddableFactory< | ||
AnomalyChartsEmbeddableState, | ||
AnomalyChartsEmbeddableApi, | ||
AnomalyChartsEmbeddableState |
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: You don't need this third type argument. The runtime state type defaults to the same as the serialized state.
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.
Thanks for the hint. Updated here 1ed16a4
} | ||
); | ||
|
||
const appliedTimeRange$: Observable<TimeRange | undefined> = combineLatest({ |
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.
Yes this is very true. Ideally fetch$
can simplify this code quite a lot!
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 latest change and LGTM.
const isMaxSeriesToPlotValid = | ||
maxSeriesToPlot >= 1 && maxSeriesToPlot <= MAX_ANOMALY_CHARTS_ALLOWED; | ||
typeof maxSeriesToPlot === 'number' && | ||
maxSeriesToPlot >= 1 && | ||
maxSeriesToPlot <= MAX_ANOMALY_CHARTS_ALLOWED; |
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 you consider using numberValidator?
x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_chart_distribution.js
Outdated
Show resolved
Hide resolved
x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_chart_distribution.js
Outdated
Show resolved
Hide resolved
x-pack/plugins/ml/public/embeddables/anomaly_charts/initialize_anomaly_charts_controls.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/ml/public/embeddables/anomaly_charts/initialize_anomaly_charts_controls.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/ml/public/embeddables/anomaly_charts/use_anomaly_charts_data.ts
Outdated
Show resolved
Hide resolved
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.
Latest changes LGTM ⚡
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.
Changes LGTM! Thank you for using the fetch$
interface. Left a few questions / nits.
const timeRange$ = useMemo( | ||
() => new BehaviorSubject(initialState.timeRange), | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[initialState.timeRange?.from, initialState.timeRange?.to] |
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.
here we're creating a new behaviour subject every time the initialState
timeRange changes? Instead, why not just .next
the existing subject when those change?
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.
We actually don't need this anymore so I've removed it here 34c2e07
return combined; | ||
}, | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[] |
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.
Because we've disabled exhaustive deps here, this component will not respond at all to changes in filters
or query
. Is this intentional?
If not, I'd suggest using a useEffect
that updates these values with .next
whenever the reactive variables change.
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.
For the purpose for this attachment to case UI, the chart is static, not changing, and is rendered based on the initial state only. The query or filters don't and should not be be updated, so initializing these behaviors upon mounting is ok.
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Async chunks
Page load bundle
Unknown metric groupsasync chunk count
ESLint disabled line counts
References to deprecated APIs
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @qn895 |
Summary
This PR addresses #174966 and migrates Anomaly charts embeddable to the new React architecture.
Adding a new Anomaly chart panel in Dashboard:
Screen.Recording.2024-05-20.at.11.20.14.mov
Saving dashboard with settings like anomaly threshold persisted
Adding a new Anomaly chart to a case
Changes include:
Checklist
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