fix: table label

This commit is contained in:
Fine 2024-04-16 14:36:23 +08:00
parent 12cd279c90
commit 7101cc93ad

View File

@ -113,16 +113,14 @@ export async function useExpressionsQueryProcessor(config: Indexable) {
typesOfMQE.push(type); typesOfMQE.push(type);
if (!obj.error) { if (!obj.error) {
if (type === ExpressionResultType.TIME_SERIES_VALUES) { 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) { for (const item of results) {
const values = item.values.map((d: { value: unknown }) => d.value) || []; const values = item.values.map((d: { value: unknown }) => d.value) || [];
const label = item.metric.labels const label = item.metric.labels
.map((d: { key: string; value: string }) => `${d.key}=${d.value}`) .map((d: { key: string; value: string }) => `${d.key}=${d.value}`)
.join(","); .join(",");
if (results.length === 1) {
source[label || c.label || name] = values;
} else {
source[label] = values; source[label] = values;
} }
} }