This commit is contained in:
Fine 2025-01-10 16:15:35 +08:00
parent ef73ace6ce
commit f152520d4e
3 changed files with 16 additions and 12 deletions

View File

@ -124,7 +124,7 @@ export const TestJson = {
results: [ results: [
{ {
metric: { metric: {
labels: [{ key: "name", value: "1" }], labels: [{ key: "p", value: "75" }],
}, },
values: [ values: [
{ {
@ -161,7 +161,7 @@ export const TestJson = {
}, },
{ {
metric: { metric: {
labels: [{ key: "name", value: "2" }], labels: [{ key: "p", value: "50" }],
}, },
values: [ values: [
{ {
@ -203,7 +203,7 @@ export const TestJson = {
results: [ results: [
{ {
metric: { metric: {
labels: [{ key: "name", value: "service_cpm1" }], labels: [{ key: "name", value: "service_resp_time1" }],
}, },
values: [ values: [
{ {
@ -215,7 +215,7 @@ export const TestJson = {
{ {
id: "202501090858", id: "202501090858",
owner: null, owner: null,
value: "29", value: "35",
traceID: null, traceID: null,
}, },
{ {
@ -227,7 +227,7 @@ export const TestJson = {
{ {
id: "202501090900", id: "202501090900",
owner: null, owner: null,
value: "155", value: "85",
traceID: null, traceID: null,
}, },
{ {
@ -240,7 +240,7 @@ export const TestJson = {
}, },
{ {
metric: { metric: {
labels: [{ key: "name", value: "service_cpm2" }], labels: [{ key: "name", value: "service_resp_time2" }],
}, },
values: [ values: [
{ {
@ -252,7 +252,7 @@ export const TestJson = {
{ {
id: "202501090858", id: "202501090858",
owner: null, owner: null,
value: "19", value: "30",
traceID: null, traceID: null,
}, },
{ {
@ -264,7 +264,7 @@ export const TestJson = {
{ {
id: "202501090900", id: "202501090900",
owner: null, owner: null,
value: "135", value: "65",
traceID: null, traceID: null,
}, },
{ {

View File

@ -27,13 +27,16 @@ export function useSnapshot(params: { name: string; results: MetricsResults[] }[
if (!r.metric.labels.length) { if (!r.metric.labels.length) {
return { values: arr }; return { values: arr };
} }
const label = r.metric.labels[0]; const name = r.metric.labels
return { name: `${label.key}=${label.value}`, values: arr }; .map((label: { key: string; value: string }) => `${label.key}=${label.value}`)
.join(",");
return { name, values: arr };
}, },
); );
return { name: metric.name, values }; return { name: metric.name, values };
}); });
return sources; return sources;
} }
@ -50,6 +53,7 @@ export function useSnapshot(params: { name: string; results: MetricsResults[] }[
} }
} }
} }
return metricsMap; return metricsMap;
} }

View File

@ -79,7 +79,7 @@ limitations under the License. -->
for (const item of metric.values) { for (const item of metric.values) {
series.push({ series.push({
data: item.values.map((item: number, itemIndex: number) => [props.intervalTime[itemIndex], item]), data: item.values.map((item: number, itemIndex: number) => [props.intervalTime[itemIndex], item]),
name: metric.name, name: item.name,
type: "line", type: "line",
symbol: "circle", symbol: "circle",
symbolSize: 4, symbolSize: 4,
@ -117,7 +117,7 @@ limitations under the License. -->
legend: { legend: {
type: "scroll", type: "scroll",
icon: "circle", icon: "circle",
top: 0, top: -5,
left: 0, left: 0,
itemWidth: 12, itemWidth: 12,
textStyle: { textStyle: {