From f152520d4eca1571abf23cdbb9a4d072ed1b282a Mon Sep 17 00:00:00 2001 From: Fine Date: Fri, 10 Jan 2025 16:15:35 +0800 Subject: [PATCH] fix --- src/hooks/data.ts | 16 ++++++++-------- src/hooks/useSnapshot.ts | 8 ++++++-- src/views/alarm/components/Line.vue | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/hooks/data.ts b/src/hooks/data.ts index c542390a..8c90cf27 100644 --- a/src/hooks/data.ts +++ b/src/hooks/data.ts @@ -124,7 +124,7 @@ export const TestJson = { results: [ { metric: { - labels: [{ key: "name", value: "1" }], + labels: [{ key: "p", value: "75" }], }, values: [ { @@ -161,7 +161,7 @@ export const TestJson = { }, { metric: { - labels: [{ key: "name", value: "2" }], + labels: [{ key: "p", value: "50" }], }, values: [ { @@ -203,7 +203,7 @@ export const TestJson = { results: [ { metric: { - labels: [{ key: "name", value: "service_cpm1" }], + labels: [{ key: "name", value: "service_resp_time1" }], }, values: [ { @@ -215,7 +215,7 @@ export const TestJson = { { id: "202501090858", owner: null, - value: "29", + value: "35", traceID: null, }, { @@ -227,7 +227,7 @@ export const TestJson = { { id: "202501090900", owner: null, - value: "155", + value: "85", traceID: null, }, { @@ -240,7 +240,7 @@ export const TestJson = { }, { metric: { - labels: [{ key: "name", value: "service_cpm2" }], + labels: [{ key: "name", value: "service_resp_time2" }], }, values: [ { @@ -252,7 +252,7 @@ export const TestJson = { { id: "202501090858", owner: null, - value: "19", + value: "30", traceID: null, }, { @@ -264,7 +264,7 @@ export const TestJson = { { id: "202501090900", owner: null, - value: "135", + value: "65", traceID: null, }, { diff --git a/src/hooks/useSnapshot.ts b/src/hooks/useSnapshot.ts index 29722e74..2788fd44 100644 --- a/src/hooks/useSnapshot.ts +++ b/src/hooks/useSnapshot.ts @@ -27,13 +27,16 @@ export function useSnapshot(params: { name: string; results: MetricsResults[] }[ if (!r.metric.labels.length) { return { values: arr }; } - const label = r.metric.labels[0]; - return { name: `${label.key}=${label.value}`, values: arr }; + const name = r.metric.labels + .map((label: { key: string; value: string }) => `${label.key}=${label.value}`) + .join(","); + return { name, values: arr }; }, ); return { name: metric.name, values }; }); + return sources; } @@ -50,6 +53,7 @@ export function useSnapshot(params: { name: string; results: MetricsResults[] }[ } } } + return metricsMap; } diff --git a/src/views/alarm/components/Line.vue b/src/views/alarm/components/Line.vue index ca4c297f..fa497b5c 100644 --- a/src/views/alarm/components/Line.vue +++ b/src/views/alarm/components/Line.vue @@ -79,7 +79,7 @@ limitations under the License. --> for (const item of metric.values) { series.push({ data: item.values.map((item: number, itemIndex: number) => [props.intervalTime[itemIndex], item]), - name: metric.name, + name: item.name, type: "line", symbol: "circle", symbolSize: 4, @@ -117,7 +117,7 @@ limitations under the License. --> legend: { type: "scroll", icon: "circle", - top: 0, + top: -5, left: 0, itemWidth: 12, textStyle: {