update menus and associate metrics

This commit is contained in:
Fine 2022-10-12 11:05:52 +08:00
parent 70732552ea
commit 9c34589f9a
5 changed files with 31 additions and 6 deletions

View File

@ -16,8 +16,8 @@ limitations under the License. -->
<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 class="menus" v-show="visMenus" ref="menus"> <div class="menus" v-show="visMenus" ref="menus">
<div class="tools"> <div class="tools" @click="associateMetrics">
{{ t("viewTrace") }} {{ t("associateMetrics") }}
</div> </div>
<div class="tools"> <div class="tools">
{{ t("viewTrace") }} {{ t("viewTrace") }}
@ -37,6 +37,7 @@ import {
} from "vue"; } from "vue";
import type { PropType } from "vue"; import type { PropType } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { EventParams } from "@/types/app";
import { useECharts } from "@/hooks/useEcharts"; import { useECharts } from "@/hooks/useEcharts";
import { addResizeListener, removeResizeListener } from "@/utils/event"; import { addResizeListener, removeResizeListener } from "@/utils/event";
@ -49,6 +50,7 @@ const visMenus = ref<boolean>(false);
const { setOptions, resize, getInstance } = useECharts( const { setOptions, resize, getInstance } = useECharts(
chartRef as Ref<HTMLDivElement> chartRef as Ref<HTMLDivElement>
); );
const currentParams = ref<Nullable<EventParams>>(null);
const props = defineProps({ const props = defineProps({
height: { type: String, default: "100%" }, height: { type: String, default: "100%" },
width: { type: String, default: "100%" }, width: { type: String, default: "100%" },
@ -84,14 +86,14 @@ onMounted(async () => {
if (!instance) { if (!instance) {
return; return;
} }
instance.on("click", (params: any) => { instance.on("click", (params: EventParams) => {
currentParams.value = params;
if (!menus.value) { if (!menus.value) {
return; return;
} }
visMenus.value = true; visMenus.value = true;
menus.value.style.left = params.event.offsetX + "px"; menus.value.style.left = params.event.offsetX + "px";
menus.value.style.top = params.event.offsetY + "px"; menus.value.style.top = params.event.offsetY + "px";
emits("select", params);
}); });
document.addEventListener( document.addEventListener(
"click", "click",
@ -99,6 +101,7 @@ onMounted(async () => {
if (instance.isDisposed()) { if (instance.isDisposed()) {
return; return;
} }
visMenus.value = false;
instance.dispatchAction({ instance.dispatchAction({
type: "hideTip", type: "hideTip",
}); });
@ -112,6 +115,11 @@ onMounted(async () => {
}, 1000); }, 1000);
}); });
function associateMetrics() {
emits("select", currentParams.value);
visMenus.value = true;
}
function updateOptions() { function updateOptions() {
const instance = getInstance(); const instance = getInstance();
if (!instance) { if (!instance) {
@ -225,7 +233,7 @@ onBeforeUnmount(() => {
display: block; display: block;
white-space: nowrap; white-space: nowrap;
z-index: 9999999; z-index: 9999999;
box-shadow: #ccc 1px 2px 10px; box-shadow: #ddd 1px 2px 10px;
transition: all cubic-bezier(0.075, 0.82, 0.165, 1) linear; transition: all cubic-bezier(0.075, 0.82, 0.165, 1) linear;
background-color: rgb(255, 255, 255); background-color: rgb(255, 255, 255);
border-radius: 4px; border-radius: 4px;
@ -234,7 +242,7 @@ onBeforeUnmount(() => {
} }
.tools { .tools {
padding: 5px 0; padding: 5px;
color: #999; color: #999;
cursor: pointer; cursor: pointer;
text-align: center; text-align: center;

View File

@ -145,6 +145,7 @@ const msg = {
pause: "Pause", pause: "Pause",
begin: "Start", begin: "Start",
associateOptions: "Association Options", associateOptions: "Association Options",
associateMetrics: "Association Metrics",
widget: "Widget", widget: "Widget",
nameTip: nameTip:
"The name only supports Chinese and English, horizontal lines and underscores. The length of the name is limited to 300 characters", "The name only supports Chinese and English, horizontal lines and underscores. The length of the name is limited to 300 characters",

View File

@ -145,6 +145,7 @@ const msg = {
pause: "Pausa", pause: "Pausa",
begin: "Inicio", begin: "Inicio",
associateOptions: "Opciones de asociación", associateOptions: "Opciones de asociación",
associateMetrics: "Índice de correlación",
widget: "Dispositivo pequeño", widget: "Dispositivo pequeño",
text: "Texto", text: "Texto",
duplicateName: "Nombre duplicado", duplicateName: "Nombre duplicado",

View File

@ -143,6 +143,7 @@ const msg = {
pause: "暂停", pause: "暂停",
begin: "开始", begin: "开始",
associateOptions: "关联选项", associateOptions: "关联选项",
associateMetrics: "关联指标",
widget: "部件", widget: "部件",
enableAssociate: "启用关联", enableAssociate: "启用关联",
nameTip: "该名称仅支持中文和英文、横线和下划线, 并且限制长度为300个字符", nameTip: "该名称仅支持中文和英文、横线和下划线, 并且限制长度为300个字符",

14
src/types/app.d.ts vendored
View File

@ -32,3 +32,17 @@ export type Paging = {
pageNum: number; pageNum: number;
pageSize: number; pageSize: number;
}; };
export type EventParams = {
componentType: string;
seriesType: string;
seriesIndex: number;
seriesName: string;
name: string;
dataIndex: number;
data: unknown;
dataType: string;
value: number | Array;
color: string;
event: any;
};