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: [
{
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,
},
{

View File

@ -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;
}

View File

@ -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: {