From 564d8a379db9e67fe9bdc1302993f2d09f9156c8 Mon Sep 17 00:00:00 2001 From: Angela Chuang Date: Fri, 12 Jan 2024 01:43:46 +0800 Subject: [PATCH] review --- .../common/components/matrix_histogram/index.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/components/matrix_histogram/index.tsx b/x-pack/plugins/security_solution/public/common/components/matrix_histogram/index.tsx index 5def1244e986f..58f1736e13792 100644 --- a/x-pack/plugins/security_solution/public/common/components/matrix_histogram/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/matrix_histogram/index.tsx @@ -82,10 +82,14 @@ const HistogramPanel = styled(Panel)<{ height?: number }>` const CHART_HEIGHT = 150; -const visualizationResponseHasData = (response: VisualizationResponse): boolean => - Object.values>(response.aggregations ?? {}).some( - ({ buckets }) => buckets.length > 0 - ); +const visualizationResponseHasData = (response: VisualizationResponse[]): boolean => { + if (response.length === 0) { + return false; + } + return Object.values>( + response[0].aggregations ?? {} + ).some(({ buckets }) => buckets.length > 0); +}; export const MatrixHistogramComponent: React.FC = ({ chartHeight, @@ -217,7 +221,7 @@ export const MatrixHistogramComponent: React.FC = if (typeof subtitle === 'function') { if (isChartEmbeddablesEnabled) { - if (!responses || !visualizationResponseHasData(responses[0])) { + if (!responses || !visualizationResponseHasData(responses)) { return subtitle(0); } const visualizationCount = responses[0].hits.total;