From f015f45601ef2b8fff4453df1b51797a329d70f0 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 15 Dec 2023 18:27:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=B3=E7=B3=BB=E5=9B=BE=E6=99=AE?= =?UTF-8?q?=E9=80=9A=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ChartGraphG6/index.vue | 178 +------------------------- 1 file changed, 1 insertion(+), 177 deletions(-) diff --git a/src/components/ChartGraphG6/index.vue b/src/components/ChartGraphG6/index.vue index b2710e1f..983d8181 100644 --- a/src/components/ChartGraphG6/index.vue +++ b/src/components/ChartGraphG6/index.vue @@ -1,19 +1,6 @@ @@ -353,24 +340,10 @@ function initChart() { container: chartGraphG6Dom.value, height: chartGraphG6Dom.value.clientHeight, width: chartGraphG6Dom.value.clientWidth, - // fitCenter: false, + fitCenter: true, modes: { default: ['drag-canvas', 'zoom-canvas', 'drag-node'], // 允许拖拽画布、放缩画布、拖拽节点 }, - // // 布局 力向吸引 - // layout: { - // type: 'force', // 指定为力导向布局 - // preventOverlap: true, // 防止节点重叠 - // linkDistance: 100, // 指定边距离为100 - // }, - // // 插件 - // plugins: [ - // { - // // 避免文本过于密集导致的视觉混乱 - // type: 'lod-controller', - // disableLod: true, - // }, - // ] as any, // 全局节点 矩形 defaultNode: { type: 'rect', @@ -401,161 +374,12 @@ function initChart() { lineWidth: 1, }, }, - // // 节点状态 - // nodeState: { - // breathing: { - // haloShape: { - // opacity: 0.25, - // lineWidth: 20, - // visible: true, - // }, - // keyShape: { - // radius: 4, - // }, - // }, - // scaling: { - // keyShape: { - // width: 100, - // height: 60, - // }, - // }, - // } as any, - // edgeState: { - // growing: { - // keyShape: { - // lineWidth: 2, - // lineDash: ['100%', 0], - // }, - // }, - // running: { - // keyShape: { - // lineWidth: 2, - // lineDash: [2, 2], - // // TODO: lineDashOffset - // }, - // }, - // }, }); graph.data(data); // 加载数据 graph.render(); // 渲染 - - graph.on('node:click', (e: any) => { - const s = graph.getItemState(e.itemId); - console.log(s); - // graph.updateData('node', { - // id: e.itemId, - // data: { - // cluster: Math.random(), - // keyShape: { - // r: 32 + Math.random() * 10 - 5, - // lineWidth: 6 + Math.random() * 6 - 3, - // stroke: '#000', - // }, - // labelShape: { - // fontWeight: 700, - // }, - // }, - // }); - }); - - graph.on('node:pointerenter', (e: any) => { - const { itemId } = e; - if (graph.getItemState(itemId, 'breathing')) { - graph.setItemState(itemId, 'breathing', false); - } else { - graph.setItemState(itemId, 'scaling', false); - graph.setItemState(itemId, 'breathing', true); - } - // graph.updateData('node', { - // id: itemId, - // data: { - // label: `after been hovered ${itemId}`, - // labelShape: { - // fill: '#0f0', - // }, - // }, - // }); - }); - - graph.on('node:pointerleave', (e: any) => { - const { itemId } = e; - if (graph.getItemState(itemId, 'breathing')) { - graph.setItemState(itemId, 'breathing', false); - } else { - graph.setItemState(itemId, 'scaling', false); - graph.setItemState(itemId, 'breathing', true); - } - // graph.updateData('node', { - // id: itemId, - // data: { - // label: 'label before been hovered', - // labelShape: { - // fill: '#000', - // }, - // }, - // }); - }); } -const actions = { - 'Enable/Disable Node States': { - Breathing: () => { - graph.getAllNodesData().forEach((node: any) => { - if (graph.getItemState(node.id, 'breathing')) { - graph.setItemState(node.id, 'breathing', false); - } else { - graph.setItemState(node.id, 'scaling', false); - graph.setItemState(node.id, 'breathing', true); - } - }); - }, - Scaling: () => { - graph.getAllNodesData().forEach((node: any) => { - if (graph.getItemState(node.id, 'scaling')) { - graph.setItemState(node.id, 'scaling', false); - } else { - graph.setItemState(node.id, 'breathing', false); - graph.setItemState(node.id, 'scaling', true); - } - }); - }, - }, - 'Enable/Disable Edge States': { - Growing: () => { - graph.getAllEdgesData().forEach((edge: any) => { - if (graph.getItemState(edge.id, 'growing')) { - graph.setItemState(edge.id, 'growing', false); - } else { - graph.setItemState(edge.id, 'running', false); - graph.setItemState(edge.id, 'growing', true); - } - }); - }, - Running: () => { - graph.getAllEdgesData().forEach((edge: any) => { - if (graph.getItemState(edge.id, 'running')) { - graph.setItemState(edge.id, 'running', false); - } else { - graph.setItemState(edge.id, 'growing', false); - graph.setItemState(edge.id, 'running', true); - } - }); - }, - }, -}; - -// watch( -// () => props.option, -// val => { -// if (val) { -// nextTick(() => { -// initChart(); -// }); -// } -// } -// ); - onMounted(() => { nextTick(() => { initChart();