diff --git a/src/hooks/useLegendProcessor.ts b/src/hooks/useLegendProcessor.ts index c9d60323..dc5f85c2 100644 --- a/src/hooks/useLegendProcessor.ts +++ b/src/hooks/useLegendProcessor.ts @@ -15,6 +15,7 @@ * limitations under the License. */ import { LegendOptions } from "@/types/dashboard"; +import { isUnDef } from "@/utils/is"; export default function useLegendProcess(legend?: LegendOptions) { let isRight = false; @@ -22,7 +23,10 @@ export default function useLegendProcess(legend?: LegendOptions) { isRight = true; } function showEchartsLegend(keys: string[]) { - if (legend && !legend.show === undefined) { + if (legend && isUnDef(legend.show)) { + if (legend.asTable && legend.show) { + return false; + } return legend.show; } if (keys.length === 1) { diff --git a/src/utils/is.ts b/src/utils/is.ts index 5f1be52f..09528f8e 100644 --- a/src/utils/is.ts +++ b/src/utils/is.ts @@ -21,7 +21,7 @@ export function is(val: unknown, type: string): boolean { } export function isDef(val?: T): val is T { - return typeof val !== "undefined"; + return typeof val === "undefined"; } export function isUnDef(val?: T): val is T { diff --git a/src/views/dashboard/configuration/Widget.vue b/src/views/dashboard/configuration/Widget.vue index 4582b702..c09a4c40 100644 --- a/src/views/dashboard/configuration/Widget.vue +++ b/src/views/dashboard/configuration/Widget.vue @@ -32,6 +32,7 @@ limitations under the License. --> :data="states.source" :config="{ ...graph, + legend: (dashboardStore.selectedGrid.graph || {}).legend, i: dashboardStore.selectedGrid.i, metrics: dashboardStore.selectedGrid.metrics, metricTypes: dashboardStore.selectedGrid.metricTypes, diff --git a/src/views/dashboard/configuration/widget/graph-styles/components/Legend.vue b/src/views/dashboard/configuration/widget/graph-styles/components/Legend.vue index f5310413..961fa544 100644 --- a/src/views/dashboard/configuration/widget/graph-styles/components/Legend.vue +++ b/src/views/dashboard/configuration/widget/graph-styles/components/Legend.vue @@ -24,7 +24,7 @@ limitations under the License. -->
{{ t("legendOptions") }} - {{ t("asTable") }} + {{ t("asTable") }}