From 7101cc93ad3ffc9bf8bba437e2ecd49b26639ca3 Mon Sep 17 00:00:00 2001 From: Fine Date: Tue, 16 Apr 2024 14:36:23 +0800 Subject: [PATCH] fix: table label --- src/hooks/useExpressionsProcessor.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/hooks/useExpressionsProcessor.ts b/src/hooks/useExpressionsProcessor.ts index 080469ae..a55a6c2c 100644 --- a/src/hooks/useExpressionsProcessor.ts +++ b/src/hooks/useExpressionsProcessor.ts @@ -113,16 +113,14 @@ export async function useExpressionsQueryProcessor(config: Indexable) { typesOfMQE.push(type); if (!obj.error) { if (type === ExpressionResultType.TIME_SERIES_VALUES) { - if (results.length === 1) { - const label = results[0].metric && results[0].metric.labels[0] && results[0].metric.labels[0].value; - source[c.label || label || name] = results[0].values.map((d: { value: unknown }) => d.value) || []; - } else { - for (const item of results) { - const values = item.values.map((d: { value: unknown }) => d.value) || []; - const label = item.metric.labels - .map((d: { key: string; value: string }) => `${d.key}=${d.value}`) - .join(","); - + for (const item of results) { + const values = item.values.map((d: { value: unknown }) => d.value) || []; + const label = item.metric.labels + .map((d: { key: string; value: string }) => `${d.key}=${d.value}`) + .join(","); + if (results.length === 1) { + source[label || c.label || name] = values; + } else { source[label] = values; } }