Merge branch 'branch_cjc4' into 'main'

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

See merge request phenomLi/StructV2!25
This commit is contained in:
cjc
2022-08-01 06:07:28 +00:00
3 changed files with 27 additions and 20 deletions
+17 -10
View File
@@ -28,8 +28,6 @@ export class SVLink extends SVModel {
label: string, label: string,
) { ) {
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;
@@ -54,14 +52,23 @@ 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 } }
// : Util.objectClone<LinkLabelOption>(options.labelOptions || ({} as LinkLabelOption));
let freed = this.target.sourceNode.freed;
// let label = this.target.sourceNode.freed ? 'freed' : '', // 简陋版:解决图的权值问题和freed结点的问题(因为结点freed后边需要显示‘freed’文本,边的权值也边也需要显示权值文本,这两个的样式有冲突),更好的解决方法(freed自己写实现逻辑,而不是用label的方案显示)
// labelCfg = this.target.sourceNode.freed let label;
// ? { position: 'start', autoRotate: true, refY: 7, style: { fontSize: 11, opacity: 0.8 } } if (freed && this.label) {
// : Util.objectClone<LinkLabelOption>(options.labelOptions || ({} as LinkLabelOption)); 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,
@@ -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,
+1 -1
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}`;
} }
+9 -9
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[]; // 变换矩阵
}; };