mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 15:04:38 +00:00
feat: Implement the legend selector in metrics charts (#447)
This commit is contained in:
parent
2b6f3ecaa8
commit
5bb4218bfe
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "skywalking-booster-ui",
|
"name": "skywalking-booster-ui",
|
||||||
"version": "9.4.0",
|
"version": "10.2.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
@ -13,6 +13,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License. -->
|
limitations under the License. -->
|
||||||
<template>
|
<template>
|
||||||
|
<SelectorLegend
|
||||||
|
:data="option.legend.data"
|
||||||
|
:show="legendSelector.isSelector"
|
||||||
|
:isConfigPage="legendSelector.isConfigPage"
|
||||||
|
:colors="option.color"
|
||||||
|
@change="changeLegend"
|
||||||
|
/>
|
||||||
<div class="chart" ref="chartRef" :style="`height:${height};width:${width};`">
|
<div class="chart" ref="chartRef" :style="`height:${height};width:${width};`">
|
||||||
<div v-if="!available" class="no-data">No Data</div>
|
<div v-if="!available" class="no-data">No Data</div>
|
||||||
<div
|
<div
|
||||||
@ -54,6 +61,7 @@ limitations under the License. -->
|
|||||||
import Trace from "@/views/dashboard/related/trace/Index.vue";
|
import Trace from "@/views/dashboard/related/trace/Index.vue";
|
||||||
import associateProcessor from "@/hooks/useAssociateProcessor";
|
import associateProcessor from "@/hooks/useAssociateProcessor";
|
||||||
import { WidgetType } from "@/views/dashboard/data";
|
import { WidgetType } from "@/views/dashboard/data";
|
||||||
|
import SelectorLegend from "./Legend.vue";
|
||||||
|
|
||||||
/*global Nullable, defineProps, defineEmits, Indexable*/
|
/*global Nullable, defineProps, defineEmits, Indexable*/
|
||||||
const emits = defineEmits(["select"]);
|
const emits = defineEmits(["select"]);
|
||||||
@ -84,6 +92,10 @@ limitations under the License. -->
|
|||||||
type: Array as PropType<{ widgetId: string }[]>,
|
type: Array as PropType<{ widgetId: string }[]>,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
|
legendSelector: {
|
||||||
|
type: Object as PropType<Indexable>,
|
||||||
|
default: () => ({ isConfigPage: false, isSelector: false }),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const available = computed(
|
const available = computed(
|
||||||
() =>
|
() =>
|
||||||
@ -103,6 +115,7 @@ limitations under the License. -->
|
|||||||
if (!instance) {
|
if (!instance) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.on("click", (params: EventParams) => {
|
instance.on("click", (params: EventParams) => {
|
||||||
currentParams.value = params;
|
currentParams.value = params;
|
||||||
if (props.option.series.type === "sankey") {
|
if (props.option.series.type === "sankey") {
|
||||||
@ -203,6 +216,23 @@ limitations under the License. -->
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeLegend(names: string[]) {
|
||||||
|
const instance = getInstance();
|
||||||
|
for (const item of props.option.legend.data) {
|
||||||
|
if (names.includes(item.name)) {
|
||||||
|
instance.dispatchAction({
|
||||||
|
type: "legendSelect",
|
||||||
|
name: item.name,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
instance.dispatchAction({
|
||||||
|
type: "legendUnSelect",
|
||||||
|
name: item.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.option,
|
() => props.option,
|
||||||
(newVal, oldVal) => {
|
(newVal, oldVal) => {
|
74
src/components/Graph/Legend.vue
Normal file
74
src/components/Graph/Legend.vue
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<!-- Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License. -->
|
||||||
|
<template>
|
||||||
|
<Selector
|
||||||
|
class="mb-10"
|
||||||
|
multiple
|
||||||
|
:value="legend"
|
||||||
|
size="small"
|
||||||
|
:options="Options"
|
||||||
|
@change="changeLegend"
|
||||||
|
filterable
|
||||||
|
collapseTags
|
||||||
|
collapseTagsTooltip
|
||||||
|
v-if="show"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref, watch } from "vue";
|
||||||
|
import type { PropType } from "vue";
|
||||||
|
import type { Option } from "@/types/app";
|
||||||
|
import Selector from "./Selector.vue";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
data: {
|
||||||
|
type: Array as PropType<{ name: string }[]>,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
colors: {
|
||||||
|
type: Array as PropType<string[]>,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
show: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
isConfigPage: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const emits = defineEmits(["change"]);
|
||||||
|
const legend = ref<string[]>([]);
|
||||||
|
const Options = computed(() =>
|
||||||
|
props.data.map((d: { name: string }, index: number) => ({
|
||||||
|
label: d.name,
|
||||||
|
value: d.name,
|
||||||
|
color: props.colors[index % props.colors.length],
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
|
function changeLegend(opt: Option[]) {
|
||||||
|
legend.value = opt.map((d: Option) => d.value);
|
||||||
|
emits("change", legend.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.data,
|
||||||
|
() => {
|
||||||
|
legend.value = props.data.map((d) => d.name);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
</script>
|
107
src/components/Graph/Selector.vue
Normal file
107
src/components/Graph/Selector.vue
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
<!-- Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License. -->
|
||||||
|
<template>
|
||||||
|
<el-select
|
||||||
|
:size="size"
|
||||||
|
v-model="selected"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
@change="changeSelected"
|
||||||
|
:multiple="multiple"
|
||||||
|
:disabled="disabled"
|
||||||
|
:style="{ borderRadius }"
|
||||||
|
:clearable="clearable"
|
||||||
|
:remote="isRemote"
|
||||||
|
:reserve-keyword="isRemote"
|
||||||
|
:remote-method="remoteMethod"
|
||||||
|
:filterable="filterable"
|
||||||
|
:collapse-tags="collapseTags"
|
||||||
|
:collapse-tags-tooltip="collapseTagsTooltip"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="(item, index) in options"
|
||||||
|
:key="`${item.value}${index}`"
|
||||||
|
:label="item.label || ''"
|
||||||
|
:value="item.value || ''"
|
||||||
|
:disabled="item.disabled || false"
|
||||||
|
>
|
||||||
|
<div class="flex items-center">
|
||||||
|
<el-tag :color="item.color" class="mr-5" size="small" />
|
||||||
|
<span :style="{ color: item.color }">{{ item.label }}</span>
|
||||||
|
</div>
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, watch } from "vue";
|
||||||
|
import type { PropType } from "vue";
|
||||||
|
|
||||||
|
/*global defineProps, defineEmits, Indexable*/
|
||||||
|
const emit = defineEmits(["change", "query"]);
|
||||||
|
const props = defineProps({
|
||||||
|
options: {
|
||||||
|
type: Array as PropType<
|
||||||
|
({
|
||||||
|
label: string | number;
|
||||||
|
value: string | number;
|
||||||
|
color: string;
|
||||||
|
} & { disabled?: boolean })[]
|
||||||
|
>,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
value: {
|
||||||
|
type: [Array, String, Number, undefined] as PropType<any>,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
size: { type: null, default: "default" },
|
||||||
|
placeholder: {
|
||||||
|
type: [String, undefined] as PropType<string>,
|
||||||
|
default: "Select a option",
|
||||||
|
},
|
||||||
|
borderRadius: { type: Number, default: 3 },
|
||||||
|
multiple: { type: Boolean, default: false },
|
||||||
|
disabled: { type: Boolean, default: false },
|
||||||
|
clearable: { type: Boolean, default: false },
|
||||||
|
isRemote: { type: Boolean, default: false },
|
||||||
|
filterable: { type: Boolean, default: true },
|
||||||
|
collapseTags: { type: Boolean, default: false },
|
||||||
|
collapseTagsTooltip: { type: Boolean, default: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const selected = ref<string[] | string>(props.value);
|
||||||
|
function changeSelected() {
|
||||||
|
const options = props.options.filter((d: Indexable) =>
|
||||||
|
props.multiple ? selected.value.includes(d.value) : selected.value === d.value,
|
||||||
|
);
|
||||||
|
emit("change", options);
|
||||||
|
}
|
||||||
|
|
||||||
|
function remoteMethod(query: string) {
|
||||||
|
if (props.isRemote) {
|
||||||
|
emit("query", query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.value,
|
||||||
|
(data) => {
|
||||||
|
selected.value = data;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.el-input__inner {
|
||||||
|
border-radius: unset !important;
|
||||||
|
}
|
||||||
|
</style>
|
@ -26,6 +26,8 @@ limitations under the License. -->
|
|||||||
:reserve-keyword="isRemote"
|
:reserve-keyword="isRemote"
|
||||||
:remote-method="remoteMethod"
|
:remote-method="remoteMethod"
|
||||||
:filterable="filterable"
|
:filterable="filterable"
|
||||||
|
:collapse-tags="collapseTags"
|
||||||
|
:collapse-tags-tooltip="collapseTagsTooltip"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(item, index) in options"
|
v-for="(item, index) in options"
|
||||||
@ -41,11 +43,6 @@ limitations under the License. -->
|
|||||||
import { ref, watch } from "vue";
|
import { ref, watch } from "vue";
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
|
|
||||||
// interface Option {
|
|
||||||
// label: string | number;
|
|
||||||
// value: string | number;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/*global defineProps, defineEmits, Indexable*/
|
/*global defineProps, defineEmits, Indexable*/
|
||||||
const emit = defineEmits(["change", "query"]);
|
const emit = defineEmits(["change", "query"]);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -73,6 +70,8 @@ limitations under the License. -->
|
|||||||
clearable: { type: Boolean, default: false },
|
clearable: { type: Boolean, default: false },
|
||||||
isRemote: { type: Boolean, default: false },
|
isRemote: { type: Boolean, default: false },
|
||||||
filterable: { type: Boolean, default: true },
|
filterable: { type: Boolean, default: true },
|
||||||
|
collapseTags: { type: Boolean, default: false },
|
||||||
|
collapseTagsTooltip: { type: Boolean, default: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
const selected = ref<string[] | string>(props.value);
|
const selected = ref<string[] | string>(props.value);
|
||||||
|
@ -18,7 +18,7 @@ import type { App } from "vue";
|
|||||||
import Icon from "./Icon.vue";
|
import Icon from "./Icon.vue";
|
||||||
import TimePicker from "./TimePicker.vue";
|
import TimePicker from "./TimePicker.vue";
|
||||||
import Selector from "./Selector.vue";
|
import Selector from "./Selector.vue";
|
||||||
import Graph from "./Graph.vue";
|
import Graph from "./Graph/Graph.vue";
|
||||||
import Radio from "./Radio.vue";
|
import Radio from "./Radio.vue";
|
||||||
import SelectSingle from "./SelectSingle.vue";
|
import SelectSingle from "./SelectSingle.vue";
|
||||||
import Tags from "./Tags.vue";
|
import Tags from "./Tags.vue";
|
||||||
|
@ -35,7 +35,7 @@ export default function useLegendProcess(legend?: LegendOptions) {
|
|||||||
if (keys.length === 1) {
|
if (keys.length === 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (legend && legend.asTable) {
|
if (legend && (legend.asTable || legend.asSelector)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -154,6 +154,7 @@ const msg = {
|
|||||||
legendOptions: "Legend Options",
|
legendOptions: "Legend Options",
|
||||||
showLegend: "Show Legend",
|
showLegend: "Show Legend",
|
||||||
asTable: "As Table",
|
asTable: "As Table",
|
||||||
|
asSelector: "As Selector",
|
||||||
toTheRight: "To The Right",
|
toTheRight: "To The Right",
|
||||||
legendValues: "Legend Values",
|
legendValues: "Legend Values",
|
||||||
minDuration: "Minimal Request Duration",
|
minDuration: "Minimal Request Duration",
|
||||||
|
@ -397,5 +397,6 @@ const msg = {
|
|||||||
instances: "Instances",
|
instances: "Instances",
|
||||||
snapshot: "Snapshot",
|
snapshot: "Snapshot",
|
||||||
expression: "Expression",
|
expression: "Expression",
|
||||||
|
asSelector: "As Selector",
|
||||||
};
|
};
|
||||||
export default msg;
|
export default msg;
|
||||||
|
@ -152,6 +152,7 @@ const msg = {
|
|||||||
legendOptions: "图例选项",
|
legendOptions: "图例选项",
|
||||||
showLegend: "显示图例",
|
showLegend: "显示图例",
|
||||||
asTable: "作为表格",
|
asTable: "作为表格",
|
||||||
|
asSelector: "作为选择器",
|
||||||
toTheRight: "在右边",
|
toTheRight: "在右边",
|
||||||
legendValues: "图例值",
|
legendValues: "图例值",
|
||||||
minDuration: "最小请求持续时间",
|
minDuration: "最小请求持续时间",
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
html {
|
html {
|
||||||
--el-color-primary: #409eff;
|
--el-color-primary: #409eff;
|
||||||
|
--el-color-info-light-9: #666;
|
||||||
--theme-background: #fff;
|
--theme-background: #fff;
|
||||||
--font-color: #3d444f;
|
--font-color: #3d444f;
|
||||||
--disabled-color: #ccc;
|
--disabled-color: #ccc;
|
||||||
@ -74,6 +75,7 @@ html {
|
|||||||
|
|
||||||
html.dark {
|
html.dark {
|
||||||
--el-color-primary: #409eff;
|
--el-color-primary: #409eff;
|
||||||
|
--el-color-info-light-9: #333;
|
||||||
--theme-background: #212224;
|
--theme-background: #212224;
|
||||||
--font-color: #fafbfc;
|
--font-color: #fafbfc;
|
||||||
--disabled-color: #999;
|
--disabled-color: #999;
|
||||||
|
3
src/types/components.d.ts
vendored
3
src/types/components.d.ts
vendored
@ -44,8 +44,9 @@ declare module 'vue' {
|
|||||||
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
||||||
ElTag: typeof import('element-plus/es')['ElTag']
|
ElTag: typeof import('element-plus/es')['ElTag']
|
||||||
ElTooltip: typeof import('element-plus/es')['ElTooltip']
|
ElTooltip: typeof import('element-plus/es')['ElTooltip']
|
||||||
Graph: typeof import('./../components/Graph.vue')['default']
|
Graph: typeof import('./../components/Graph/Graph.vue')['default']
|
||||||
Icon: typeof import('./../components/Icon.vue')['default']
|
Icon: typeof import('./../components/Icon.vue')['default']
|
||||||
|
Legend: typeof import('./../components/Graph/Legend.vue')['default']
|
||||||
Radio: typeof import('./../components/Radio.vue')['default']
|
Radio: typeof import('./../components/Radio.vue')['default']
|
||||||
RouterLink: typeof import('vue-router')['RouterLink']
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
RouterView: typeof import('vue-router')['RouterView']
|
RouterView: typeof import('vue-router')['RouterView']
|
||||||
|
2
src/types/dashboard.d.ts
vendored
2
src/types/dashboard.d.ts
vendored
@ -112,7 +112,6 @@ export interface LineConfig extends AreaConfig {
|
|||||||
smallTips?: boolean;
|
smallTips?: boolean;
|
||||||
showlabels?: boolean;
|
showlabels?: boolean;
|
||||||
noTooltips?: boolean;
|
noTooltips?: boolean;
|
||||||
showLegend?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AreaConfig {
|
export interface AreaConfig {
|
||||||
@ -198,6 +197,7 @@ export type LegendOptions = {
|
|||||||
asTable: boolean;
|
asTable: boolean;
|
||||||
toTheRight: boolean;
|
toTheRight: boolean;
|
||||||
width: number;
|
width: number;
|
||||||
|
asSelector: boolean;
|
||||||
};
|
};
|
||||||
export type MetricsResults = {
|
export type MetricsResults = {
|
||||||
metric: { labels: MetricLabel[] };
|
metric: { labels: MetricLabel[] };
|
||||||
|
@ -22,6 +22,15 @@ limitations under the License. -->
|
|||||||
@change="updateLegendConfig({ show: legend.show })"
|
@change="updateLegendConfig({ show: legend.show })"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<span class="label mr-5">{{ t("asSelector") }}</span>
|
||||||
|
<el-switch
|
||||||
|
v-model="legend.asSelector"
|
||||||
|
active-text="Yes"
|
||||||
|
inactive-text="No"
|
||||||
|
@change="updateLegendConfig({ asSelector: legend.asSelector })"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span class="label">{{ t("asTable") }}</span>
|
<span class="label">{{ t("asTable") }}</span>
|
||||||
<el-switch
|
<el-switch
|
||||||
@ -97,6 +106,7 @@ limitations under the License. -->
|
|||||||
max: false,
|
max: false,
|
||||||
mean: false,
|
mean: false,
|
||||||
asTable: false,
|
asTable: false,
|
||||||
|
asSelector: false,
|
||||||
toTheRight: false,
|
toTheRight: false,
|
||||||
width: 130,
|
width: 130,
|
||||||
...graph.value.legend,
|
...graph.value.legend,
|
||||||
|
@ -75,6 +75,34 @@ limitations under the License. -->
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
const color: string[] = chartColors();
|
const color: string[] = chartColors();
|
||||||
|
const legend =
|
||||||
|
appStore.theme === Themes.Dark
|
||||||
|
? {
|
||||||
|
pageIconColor: "#ccc",
|
||||||
|
pageIconInactiveColor: "#444",
|
||||||
|
backgroundColor: "#333",
|
||||||
|
borderColor: "#fff",
|
||||||
|
textStyle: {
|
||||||
|
fontSize: 12,
|
||||||
|
color: "#eee",
|
||||||
|
},
|
||||||
|
pageTextStyle: {
|
||||||
|
color: "#eee",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
pageIconColor: "#666",
|
||||||
|
pageIconInactiveColor: "#ccc",
|
||||||
|
backgroundColor: appStore.theme === Themes.Dark ? "#333" : "#fff",
|
||||||
|
borderColor: appStore.theme === Themes.Dark ? "#333" : "#fff",
|
||||||
|
textStyle: {
|
||||||
|
fontSize: 12,
|
||||||
|
color: "#333",
|
||||||
|
},
|
||||||
|
pageTextStyle: {
|
||||||
|
color: "#333",
|
||||||
|
},
|
||||||
|
};
|
||||||
return {
|
return {
|
||||||
color,
|
color,
|
||||||
tooltip: {
|
tooltip: {
|
||||||
@ -94,15 +122,10 @@ limitations under the License. -->
|
|||||||
top: 0,
|
top: 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
itemWidth: 12,
|
itemWidth: 12,
|
||||||
backgroundColor: appStore.theme === Themes.Dark ? "#333" : "#fff",
|
...legend,
|
||||||
borderColor: appStore.theme === Themes.Dark ? "#333" : "#fff",
|
|
||||||
textStyle: {
|
|
||||||
fontSize: 12,
|
|
||||||
color: appStore.theme === Themes.Dark ? "#eee" : "#333",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
top: keys.length === 1 ? 15 : 40,
|
top: showEchartsLegend(keys) ? 35 : 10,
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 10,
|
right: 10,
|
||||||
bottom: 5,
|
bottom: 5,
|
||||||
|
@ -16,10 +16,11 @@ limitations under the License. -->
|
|||||||
<div class="graph flex-v" :class="setRight ? 'flex-h' : 'flex-v'">
|
<div class="graph flex-v" :class="setRight ? 'flex-h' : 'flex-v'">
|
||||||
<Graph
|
<Graph
|
||||||
:option="option"
|
:option="option"
|
||||||
@select="clickEvent"
|
|
||||||
:filters="config.filters"
|
:filters="config.filters"
|
||||||
:relatedTrace="config.relatedTrace"
|
:relatedTrace="config.relatedTrace"
|
||||||
:associate="config.associate || []"
|
:associate="config.associate || []"
|
||||||
|
:legendSelector="{ isSelector: legendSelector, sConfigPage: dashboardStore.showConfig }"
|
||||||
|
@select="clickEvent"
|
||||||
/>
|
/>
|
||||||
<Legend :config="config.legend" :data="data" :intervalTime="intervalTime" />
|
<Legend :config="config.legend" :data="data" :intervalTime="intervalTime" />
|
||||||
</div>
|
</div>
|
||||||
@ -32,6 +33,7 @@ limitations under the License. -->
|
|||||||
import useLegendProcess from "@/hooks/useLegendProcessor";
|
import useLegendProcess from "@/hooks/useLegendProcessor";
|
||||||
import { isDef } from "@/utils/is";
|
import { isDef } from "@/utils/is";
|
||||||
import { useAppStoreWithOut } from "@/store/modules/app";
|
import { useAppStoreWithOut } from "@/store/modules/app";
|
||||||
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
import { Themes } from "@/constants/data";
|
import { Themes } from "@/constants/data";
|
||||||
|
|
||||||
/*global defineProps, defineEmits */
|
/*global defineProps, defineEmits */
|
||||||
@ -61,12 +63,13 @@ limitations under the License. -->
|
|||||||
smallTips: false,
|
smallTips: false,
|
||||||
showlabels: true,
|
showlabels: true,
|
||||||
noTooltips: false,
|
noTooltips: false,
|
||||||
showLegend: true,
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const appStore = useAppStoreWithOut();
|
const appStore = useAppStoreWithOut();
|
||||||
|
const dashboardStore = useDashboardStore();
|
||||||
const setRight = ref<boolean>(false);
|
const setRight = ref<boolean>(false);
|
||||||
|
const legendSelector = computed(() => props.config.legend?.asSelector);
|
||||||
const option = computed(() => getOption());
|
const option = computed(() => getOption());
|
||||||
function getOption() {
|
function getOption() {
|
||||||
const { showEchartsLegend, isRight, chartColors } = useLegendProcess(props.config.legend);
|
const { showEchartsLegend, isRight, chartColors } = useLegendProcess(props.config.legend);
|
||||||
@ -124,27 +127,49 @@ limitations under the License. -->
|
|||||||
color: appStore.theme === Themes.Dark ? "#eee" : "#333",
|
color: appStore.theme === Themes.Dark ? "#eee" : "#333",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
const legend =
|
||||||
|
appStore.theme === Themes.Dark
|
||||||
|
? {
|
||||||
|
pageIconColor: "#ccc",
|
||||||
|
pageIconInactiveColor: "#444",
|
||||||
|
textStyle: {
|
||||||
|
fontSize: 12,
|
||||||
|
color: "#eee",
|
||||||
|
},
|
||||||
|
pageTextStyle: {
|
||||||
|
color: "#eee",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
pageIconColor: "#666",
|
||||||
|
pageIconInactiveColor: "#ccc",
|
||||||
|
textStyle: {
|
||||||
|
fontSize: 12,
|
||||||
|
color: "#333",
|
||||||
|
},
|
||||||
|
pageTextStyle: {
|
||||||
|
color: "#333",
|
||||||
|
},
|
||||||
|
};
|
||||||
return {
|
return {
|
||||||
color,
|
color,
|
||||||
tooltip: props.config.smallTips ? tips : tooltip,
|
tooltip: props.config.smallTips ? tips : tooltip,
|
||||||
legend: {
|
legend: {
|
||||||
type: "scroll",
|
type: "scroll",
|
||||||
show: props.config.showLegend ? showEchartsLegend(keys) : false,
|
show: showEchartsLegend(keys),
|
||||||
icon: "circle",
|
icon: "circle",
|
||||||
top: 0,
|
top: 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
itemWidth: 12,
|
itemWidth: 12,
|
||||||
textStyle: {
|
data: keys.map((d: string) => ({ name: d })),
|
||||||
color: appStore.theme === Themes.Dark ? "#fff" : "#333",
|
...legend,
|
||||||
},
|
|
||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
top: showEchartsLegend(keys) ? 35 : 10,
|
top: showEchartsLegend(keys) ? 35 : 10,
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 10,
|
right: 10,
|
||||||
bottom: 5,
|
bottom: 5,
|
||||||
containLabel: props.config.showlabels === undefined ? true : props.config.showlabels,
|
containLabel: isDef(props.config.showlabels) ? props.config.showlabels : true,
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: "category",
|
type: "category",
|
||||||
|
Loading…
Reference in New Issue
Block a user