From 7cfd25aebe5869244e40dbbcd6384f115f35e66e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 14 六月 2023 09:37:21 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/menu/components/chart/antv-X6/index.jsx | 114 ++++++++++++++++++++++++--------------------------------- 1 files changed, 48 insertions(+), 66 deletions(-) diff --git a/src/menu/components/chart/antv-X6/index.jsx b/src/menu/components/chart/antv-X6/index.jsx index 5ace0da..6d20b17 100644 --- a/src/menu/components/chart/antv-X6/index.jsx +++ b/src/menu/components/chart/antv-X6/index.jsx @@ -336,21 +336,24 @@ // #region 鍒濆鍖栫敾甯� const graph = new Graph({ container: document.getElementById(card.uuid + 'container'), - // grid: true, - grid: { - visible: true, - type: 'doubleMesh', - args: [ - { - color: '#eee', // 涓荤綉鏍肩嚎棰滆壊 - thickness: 1 // 涓荤綉鏍肩嚎瀹藉害 - }, - { - color: '#ddd', // 娆$綉鏍肩嚎棰滆壊 - thickness: 1, // 娆$綉鏍肩嚎瀹藉害 - factor: 4 // 涓绘缃戞牸绾块棿闅� - } - ] + // grid: { + // visible: true, + // type: 'doubleMesh', + // args: [ + // { + // color: '#eee', // 涓荤綉鏍肩嚎棰滆壊 + // thickness: 1 // 涓荤綉鏍肩嚎瀹藉害 + // }, + // { + // color: '#ddd', // 娆$綉鏍肩嚎棰滆壊 + // thickness: 1, // 娆$綉鏍肩嚎瀹藉害 + // factor: 4 // 涓绘缃戞牸绾块棿闅� + // } + // ] + // }, + scaling: { + min: 0.5, + max: 2 }, autoResize: true, panning: true, @@ -360,9 +363,7 @@ mousewheel: { enabled: true, zoomAtMousePosition: true, - modifiers: 'ctrl', - minScale: 0.5, - maxScale: 2 + modifiers: 'ctrl' }, connecting: { router: 'manhattan', @@ -469,9 +470,7 @@ }) graph.bindKey(['meta+v', 'ctrl+v'], () => { if (!graph.isClipboardEmpty()) { - const cells = graph.paste({ offset: 32 }) - graph.cleanSelection() - graph.select(cells) + graph.paste({ offset: 32 }) } return false }) @@ -490,35 +489,15 @@ return false }) - // select all - graph.bindKey(['meta+a', 'ctrl+a'], () => { - const nodes = graph.getNodes() - if (nodes) { - graph.select(nodes) - } - }) - - // delete - graph.bindKey('backspace', () => { + // 鍒犻櫎鍏冪礌 + graph.bindKey(['backspace', 'delete'], () => { const cells = graph.getSelectedCells() if (cells.length) { graph.removeCells(cells) + this.selectNode = null + this.setState({node: null}) } }) - - // zoom - // graph.bindKey(['ctrl+1', 'meta+1'], () => { - // const zoom = graph.zoom() - // if (zoom < 1.5) { - // graph.zoom(0.1) - // } - // }) - // graph.bindKey(['ctrl+2', 'meta+2'], () => { - // const zoom = graph.zoom() - // if (zoom > 0.5) { - // graph.zoom(-0.1) - // } - // }) // 鎺у埗杩炴帴妗╂樉绀�/闅愯棌 const showPorts = (ports, show) => { @@ -537,23 +516,17 @@ showPorts(ports, false) }) - // graph.on('cell:click', ({ e, x, y, cell, view }) => { - // cell.attr('body/stroke', "red") - // }) graph.on('node:click', ({ e, x, y, node, view }) => { this.selectNode = node - this.setState({node: this.selectNode.store.data}) + this.setState({node: node.store.data}) }) graph.on('edge:click', ({ e, x, y, edge, view }) => { this.selectNode = edge - this.setState({node: this.selectNode.store.data}) - - let trans = document.querySelectorAll('.x6-widget-transform') - if (trans && trans[0]) { - trans[0].style.display = 'none' - } + this.setState({node: edge.store.data}) + + graph.clearTransformWidgets() }) graph.on('blank:click', ({ e, x, y }) => { this.selectNode = null @@ -641,20 +614,13 @@ this.selectNode.toBack() } + // zoom() 鍙幏鍙栨垨鑰呰缃缉鏀炬瘮渚� setZoomIn = () => { - const zoom = this.mkGraph.zoom() - - if (zoom < 2) { - this.mkGraph.zoom(0.1) - } + this.mkGraph.zoom(0.1) } setZoomOut = () => { - const zoom = this.mkGraph.zoom() - - if (zoom > 0.5) { - this.mkGraph.zoom(-0.1) - } + this.mkGraph.zoom(-0.1) } setZoomInt = () => { @@ -669,7 +635,23 @@ const { node } = this.state if (node.shape === 'edge') { - + if (key === 'title') { + this.selectNode.setLabels(value) + } else if (key === 'stroke') { + this.selectNode.attr('line/stroke', value) + } else if (key === 'strokeWidth') { + this.selectNode.attr('line/strokeWidth', value) + } else if (key === 'lineType') { + if (value === 'dash') { + this.selectNode.attr('line/strokeDasharray', 5) + } else { + this.selectNode.attr('line/strokeDasharray', 0) + } + } else if (key === 'fontSize') { + this.selectNode.attr('text/fontSize', value) + } else if (key === 'fontFill') { + this.selectNode.attr('text/fill', value) + } } else { if (key === 'title') { this.selectNode.attr('text/text', value) -- Gitblit v1.8.0