diff --git a/src/components/Graph.vue b/src/components/Graph.vue index 1822fbbf..094fbf91 100644 --- a/src/components/Graph.vue +++ b/src/components/Graph.vue @@ -49,17 +49,13 @@ import type { PropType } from "vue"; import { useI18n } from "vue-i18n"; import { EventParams } from "@/types/app"; import { useECharts } from "@/hooks/useEcharts"; -import { useAppStoreWithOut } from "@/store/modules/app"; import { addResizeListener, removeResizeListener } from "@/utils/event"; import Trace from "@/views/dashboard/controls/Trace.vue"; -import dateFormatStep from "@/utils/dateFormat"; -import getLocalTime from "@/utils/localtime"; import associateProcessor from "@/hooks/useAssociateProcessor"; /*global Nullable, defineProps, defineEmits*/ const emits = defineEmits(["select"]); const { t } = useI18n(); -const appStore = useAppStoreWithOut(); const chartRef = ref>(null); const menus = ref>(null); const visMenus = ref(false); @@ -153,8 +149,8 @@ function updateOptions() { return; } if (props.filters.isRange) { - const { eventAssociate } = associateProcessor(); - const options = eventAssociate(props); + const { eventAssociate } = associateProcessor(props); + const options = eventAssociate(); setOptions(options || props.option); } else { instance.dispatchAction({ @@ -166,8 +162,7 @@ function updateOptions() { } function viewTrace() { - const item = associateProcessor().traceFilters(currentParams.value); - console.log(item); + const item = associateProcessor(props).traceFilters(currentParams.value); traceOptions.value = { ...traceOptions.value, filters: item, @@ -186,8 +181,8 @@ watch( } let options; if (props.filters && props.filters.isRange) { - const { eventAssociate } = associateProcessor(); - options = eventAssociate(props); + const { eventAssociate } = associateProcessor(props); + options = eventAssociate(); } setOptions(options || props.option); } diff --git a/src/hooks/useAssociateProcessor.ts b/src/hooks/useAssociateProcessor.ts index 3ae4ea4d..1c98cc74 100644 --- a/src/hooks/useAssociateProcessor.ts +++ b/src/hooks/useAssociateProcessor.ts @@ -1,3 +1,4 @@ +import { Option } from "@/types/app"; /** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -18,9 +19,10 @@ import { useAppStoreWithOut } from "@/store/modules/app"; import dateFormatStep from "@/utils/dateFormat"; import getLocalTime from "@/utils/localtime"; import { QueryOrders } from "@/views/dashboard/data"; +import { EventParams } from "@/types/app"; -export default function associateProcessor() { - function eventAssociate(props: any) { +export default function associateProcessor(props: any) { + function eventAssociate() { if (!props.filters) { return; } @@ -64,7 +66,7 @@ export default function associateProcessor() { }; return options; } - function traceFilters(currentParams: any) { + function traceFilters(currentParams: Nullable) { const appStore = useAppStoreWithOut(); if (!currentParams) { @@ -92,6 +94,7 @@ export default function associateProcessor() { } let queryOrder = QueryOrders[1].value; let status = undefined; + let latency = undefined; if (currentParams.seriesName.includes("_sla")) { queryOrder = QueryOrders[0].value; status = "ERROR"; @@ -99,10 +102,18 @@ export default function associateProcessor() { if (currentParams.seriesName.includes("_apdex")) { status = "ERROR"; } + if (props.option.series) { + latency = props.option.series.map( + (d: { name: string; data: number[][] }) => { + return { [d.name]: d.data[currentParams.dataIndex] }; + } + ); + } const item = { duration, queryOrder, status, + latency, }; return item; } diff --git a/src/store/modules/trace.ts b/src/store/modules/trace.ts index 60bf8e67..8d74f7ee 100644 --- a/src/store/modules/trace.ts +++ b/src/store/modules/trace.ts @@ -57,7 +57,6 @@ export const traceStore = defineStore({ actions: { setTraceCondition(data: any) { this.conditions = { ...this.conditions, ...data }; - console.log(this.conditions.queryOrder); }, setCurrentTrace(trace: Trace) { this.currentTrace = trace;