修改freed结点后和图结构的边权重问题的冲突的bug

This commit is contained in:
cjc 2022-08-01 11:52:15 +08:00
parent 267cf35e87
commit 551dc7057f
3 changed files with 27 additions and 20 deletions

View File

@ -29,8 +29,6 @@ export class SVLink extends SVModel {
) { ) {
super(id, type, group, layout, 'link'); super(id, type, group, layout, 'link');
console.log(id);
this.node = node; this.node = node;
this.target = target; this.target = target;
this.nodeId = node.id; this.nodeId = node.id;
@ -54,15 +52,24 @@ export class SVLink extends SVModel {
if (options.targetAnchor && typeof options.targetAnchor === 'function' && this.linkIndex !== null) { if (options.targetAnchor && typeof options.targetAnchor === 'function' && this.linkIndex !== null) {
targetAnchor = options.targetAnchor(this.linkIndex); targetAnchor = options.targetAnchor(this.linkIndex);
} }
let labelCfg = this.label? { position: 'middle', autoRotate: true, refY: 7, style: { fontSize: 20, opacity: 0.8 } } let labelCfg = Util.objectClone<LinkLabelOption>(options.labelOptions || ({} as LinkLabelOption));
: Util.objectClone<LinkLabelOption>(options.labelOptions || ({} as LinkLabelOption)); // let labelCfg = this.label? { position: 'middle', autoRotate: true, refY: 7, style: { fontSize: 20, opacity: 0.8 } }
// 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<LinkLabelOption>(options.labelOptions || ({} as LinkLabelOption)); // : Util.objectClone<LinkLabelOption>(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 { return {
id: this.id, id: this.id,
type: options.type, type: options.type,
@ -70,7 +77,7 @@ export class SVLink extends SVModel {
target: this.target.id, target: this.target.id,
sourceAnchor, sourceAnchor,
targetAnchor, targetAnchor,
label:this.label, label:label,
style: Util.objectClone<Style>(options.style), style: Util.objectClone<Style>(options.style),
labelCfg, labelCfg,
curveOffset: options.curveOffset, curveOffset: options.curveOffset,

View File

@ -394,7 +394,7 @@ export class ModelConstructor {
let id; let id;
// 如果数据结构是图则不需要index来区分是哪条边 // 如果数据结构是图则不需要index来区分是哪条边
if (layout.indexOf('Graph') !== -1) { if (layout.indexOf('Graph') !== -1) {
id = `${linkName}{${node.id}-${target.id}}`; id = `{${node.id}-${target.id}}`;
} else { } else {
id = `${linkName}{${node.id}-${target.id}}#${index}`; id = `${linkName}{${node.id}-${target.id}}#${index}`;
} }

View File

@ -5,15 +5,15 @@ import { ELayoutMode } from "./View/layoutProvider";
export interface Style { export interface Style {
fill: string; // 填充颜色 fill?: string; // 填充颜色
text: string; // 图形文本 text?: string; // 图形文本
textFill: string; // 文本颜色 textFill?: string; // 文本颜色
fontSize: number; // 字体大小 fontSize?: number; // 字体大小
fontWeight: number; // 字重 fontWeight?: number; // 字重
stroke: string; // 描边样式 stroke?: string; // 描边样式
opacity: number; // 透明度 opacity?: number; // 透明度
lineWidth: number; // 线宽 lineWidth?: number; // 线宽
matrix: number[]; // 变换矩阵 matrix?: number[]; // 变换矩阵
}; };