From 267cf35e872d4d4b6d39625f6fbfba9653b0c2bd Mon Sep 17 00:00:00 2001 From: cjc <431909623@qq.com> Date: Sun, 31 Jul 2022 10:25:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BE=B9=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=9D=83=E5=80=BC=E7=9A=84bug=EF=BC=88?= =?UTF-8?q?=E5=92=8C=E9=87=8A=E6=94=BE=E6=8C=87=E9=92=88=E6=97=B6=E5=9C=A8?= =?UTF-8?q?=E8=BE=B9=E4=B8=8A=E6=98=BE=E7=A4=BAfree=E8=BF=99=E4=B8=AAbug?= =?UTF-8?q?=E5=86=B2=E7=AA=81=EF=BC=8C=E5=BE=85=E8=A7=A3=E5=86=B3=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Model/SVLink.ts | 20 ++++++++++++++------ src/Model/modelConstructor.ts | 22 +++++++++++++++++----- src/View/animation.ts | 8 +++++--- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/Model/SVLink.ts b/src/Model/SVLink.ts index 5ec776d..435b2d3 100644 --- a/src/Model/SVLink.ts +++ b/src/Model/SVLink.ts @@ -7,6 +7,7 @@ import { SVNode } from './SVNode'; export class SVLink extends SVModel { public node: SVNode; public target: SVNode; + public label: string; //边的权值 public linkIndex: number; public shadowG6Item: IEdge; @@ -23,15 +24,19 @@ export class SVLink extends SVModel { node: SVNode, target: SVNode, index: number, - options: LinkOption + options: LinkOption, + label: string, ) { super(id, type, group, layout, 'link'); + console.log(id); + this.node = node; this.target = target; this.nodeId = node.id; this.targetId = target.id; this.linkIndex = index; + this.label = label; //边的权值 node.links.outDegree.push(this); target.links.inDegree.push(this); @@ -49,11 +54,14 @@ 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 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 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)); return { id: this.id, @@ -62,7 +70,7 @@ export class SVLink extends SVModel { target: this.target.id, sourceAnchor, targetAnchor, - label, + label:this.label, style: Util.objectClone