From 9d8400f2d2b75fd2e99dd792316428c744f660b7 Mon Sep 17 00:00:00 2001 From: yaojiping Date: Mon, 13 Jan 2025 07:40:30 +0800 Subject: [PATCH] chore: the first metric is selected by default in TopN --- .../Platform/Overview/components/TopN/index.jsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/web/src/pages/Platform/Overview/components/TopN/index.jsx b/web/src/pages/Platform/Overview/components/TopN/index.jsx index 06a85114..311986a6 100644 --- a/web/src/pages/Platform/Overview/components/TopN/index.jsx +++ b/web/src/pages/Platform/Overview/components/TopN/index.jsx @@ -52,6 +52,17 @@ export default (props) => { return true; }).map((item) => ({ ...item._source })) setMetrics(newMetrics) + if (newMetrics.length > 0 && (!formData.sourceArea && !formData.sourceColor)) { + const newFormData = { + ...cloneDeep(formData), + sourceArea: newMetrics[0], + statisticArea: newMetrics[0]?.items[0]?.statistic, + sourceColor: newMetrics[0], + statisticColor: newMetrics[0].items[0]?.statistic + } + setFormData(newFormData) + fetchData(type, clusterID, timeRange, newFormData) + } } setLoading(false) } @@ -283,6 +294,7 @@ export default (props) => { { if (value) { const { items = [] } = option?.props?.metric || {} @@ -361,6 +375,7 @@ export default (props) => {