Merge branch 'branch_cjc4' into 'main'
修改边不能显示权值的bug(和释放指针时在边上显示free这个bug冲突,待解决) See merge request phenomLi/StructV2!24
This commit is contained in:
commit
95265a3a9d
@ -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,12 +54,15 @@ export class SVLink extends SVModel {
|
||||
if (options.targetAnchor && typeof options.targetAnchor === 'function' && this.linkIndex !== null) {
|
||||
targetAnchor = options.targetAnchor(this.linkIndex);
|
||||
}
|
||||
|
||||
let label = this.target.sourceNode.freed ? 'freed' : '',
|
||||
labelCfg = this.target.sourceNode.freed
|
||||
? { position: 'start', autoRotate: true, refY: 7, style: { fontSize: 11, opacity: 0.8 } }
|
||||
let labelCfg = this.label? { position: 'middle', autoRotate: true, refY: 7, style: { fontSize: 20, opacity: 0.8 } }
|
||||
: Util.objectClone<LinkLabelOption>(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<LinkLabelOption>(options.labelOptions || ({} as LinkLabelOption));
|
||||
|
||||
return {
|
||||
id: this.id,
|
||||
type: options.type,
|
||||
@ -62,7 +70,7 @@ export class SVLink extends SVModel {
|
||||
target: this.target.id,
|
||||
sourceAnchor,
|
||||
targetAnchor,
|
||||
label,
|
||||
label:this.label,
|
||||
style: Util.objectClone<Style>(options.style),
|
||||
labelCfg,
|
||||
curveOffset: options.curveOffset,
|
||||
|
@ -169,8 +169,10 @@ export class ModelConstructor {
|
||||
linkNames = Object.keys(linkOptions);
|
||||
|
||||
linkNames.forEach(name => {
|
||||
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
let node: SVNode = nodes[i],
|
||||
value,
|
||||
sourceLinkData: sourceLinkData = node.sourceNode[name],
|
||||
targetNode: SVNode | SVNode[] = null,
|
||||
link: SVLink = null;
|
||||
@ -183,11 +185,18 @@ export class ModelConstructor {
|
||||
// ------------------- 将连接声明字段 sourceLinkData 从 id 变为 SVNode -------------------
|
||||
if (Array.isArray(sourceLinkData)) {
|
||||
node[name] = sourceLinkData.map((item, index) => {
|
||||
// 提取权值
|
||||
if (typeof item === 'string' && item.includes('/')) {
|
||||
value = item.split('/')[1];
|
||||
item = item.split('/')[0];
|
||||
}
|
||||
|
||||
targetNode = this.fetchTargetNodes(layoutGroupTable, node, item);
|
||||
let isGeneralLink = ModelConstructor.isGeneralLink(sourceLinkData.toString());
|
||||
|
||||
if (targetNode) {
|
||||
link = this.createLink(name, group, layout, node, targetNode, index, linkOptions[name]);
|
||||
link = this.createLink(name, group, layout, node, targetNode, index, linkOptions[name],value);
|
||||
|
||||
linkList.push(link);
|
||||
}
|
||||
|
||||
@ -198,7 +207,7 @@ export class ModelConstructor {
|
||||
let isGeneralLink = ModelConstructor.isGeneralLink(sourceLinkData.toString());
|
||||
|
||||
if (targetNode) {
|
||||
link = this.createLink(name, group, layout, node, targetNode, 0, linkOptions[name]);
|
||||
link = this.createLink(name, group, layout, node, targetNode, 0, linkOptions[name],value);
|
||||
linkList.push(link);
|
||||
}
|
||||
|
||||
@ -379,7 +388,8 @@ export class ModelConstructor {
|
||||
node: SVNode,
|
||||
target: SVNode,
|
||||
index: number,
|
||||
options: LinkOption
|
||||
options: LinkOption,
|
||||
label: string
|
||||
): SVLink {
|
||||
let id;
|
||||
// 如果数据结构是图,则不需要index来区分是哪条边
|
||||
@ -388,7 +398,7 @@ export class ModelConstructor {
|
||||
} else {
|
||||
id = `${linkName}{${node.id}-${target.id}}#${index}`;
|
||||
}
|
||||
return new SVLink(id, linkName, group, layout, node, target, index, options);
|
||||
return new SVLink(id, linkName, group, layout, node, target, index, options,label);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -428,6 +438,8 @@ export class ModelConstructor {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (typeof linkTarget === 'number' || (typeof linkTarget === 'string' && !linkTarget.includes('#'))) {
|
||||
linkTarget = 'default#' + linkTarget;
|
||||
}
|
||||
|
@ -30,9 +30,11 @@ export const Animations = {
|
||||
let matrix = group.getMatrix(),
|
||||
targetMatrix = Mat3.clone(matrix);
|
||||
|
||||
Mat3.scale(matrix, matrix, [0, 0]);
|
||||
// 让结点大小从0到1出现
|
||||
Mat3.scale(matrix, matrix, [0, 0]);//第一个参数的matrix是你要更改的矩阵,第二个参数是更改之后的新矩阵,第三个参数就是缩放系数,分别对应xy
|
||||
Mat3.scale(targetMatrix, targetMatrix, [1, 1]);
|
||||
|
||||
// 让结点透明度从0到1
|
||||
group.attr({ matrix, opacity: 0 });
|
||||
group.animate({ matrix: targetMatrix, opacity: 1 }, animateCfg);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user