From 551dc7057f90705e7f4686ffc428b45c418e259b Mon Sep 17 00:00:00 2001 From: cjc <431909623@qq.com> Date: Mon, 1 Aug 2022 11:52:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9freed=E7=BB=93=E7=82=B9?= =?UTF-8?q?=E5=90=8E=E5=92=8C=E5=9B=BE=E7=BB=93=E6=9E=84=E7=9A=84=E8=BE=B9?= =?UTF-8?q?=E6=9D=83=E9=87=8D=E9=97=AE=E9=A2=98=E7=9A=84=E5=86=B2=E7=AA=81?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Model/SVLink.ts | 27 +++++++++++++++++---------- src/Model/modelConstructor.ts | 2 +- src/options.ts | 18 +++++++++--------- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/Model/SVLink.ts b/src/Model/SVLink.ts index 435b2d3..88c0b99 100644 --- a/src/Model/SVLink.ts +++ b/src/Model/SVLink.ts @@ -28,8 +28,6 @@ export class SVLink extends SVModel { label: string, ) { super(id, type, group, layout, 'link'); - - console.log(id); this.node = node; this.target = target; @@ -54,14 +52,23 @@ export class SVLink extends SVModel { if (options.targetAnchor && typeof options.targetAnchor === 'function' && this.linkIndex !== null) { targetAnchor = options.targetAnchor(this.linkIndex); } - let labelCfg = this.label? { position: 'middle', autoRotate: true, refY: 7, style: { fontSize: 20, opacity: 0.8 } } - : Util.objectClone(options.labelOptions || ({} as LinkLabelOption)); + let labelCfg = Util.objectClone(options.labelOptions || ({} as LinkLabelOption)); + // let labelCfg = this.label? { position: 'middle', autoRotate: true, refY: 7, style: { fontSize: 20, opacity: 0.8 } } + // : Util.objectClone(options.labelOptions || ({} as LinkLabelOption)); - - // let label = this.target.sourceNode.freed ? 'freed' : '', - // labelCfg = this.target.sourceNode.freed - // ? { position: 'start', autoRotate: true, refY: 7, style: { fontSize: 11, opacity: 0.8 } } - // : Util.objectClone(options.labelOptions || ({} as LinkLabelOption)); + let freed = this.target.sourceNode.freed; + // 简陋版:解决图的权值问题和freed结点的问题(因为结点freed后边需要显示‘freed’文本,边的权值也边也需要显示权值文本,这两个的样式有冲突),更好的解决方法(freed自己写实现逻辑,而不是用label的方案显示) + let label; + if (freed && this.label) { + label = this.label + '(freed)'; + } else if(!freed && this.label) { + label = this.label; + } else if (freed && !this.label) { + label = 'freed' + labelCfg ={ position: 'start', autoRotate: true, refY: 7, refX: 0, style: { fontSize: 11, opacity: 0.8 } } + console.log(labelCfg); + + } return { id: this.id, @@ -70,7 +77,7 @@ export class SVLink extends SVModel { target: this.target.id, sourceAnchor, targetAnchor, - label:this.label, + label:label, style: Util.objectClone