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 {
|
export class SVLink extends SVModel {
|
||||||
public node: SVNode;
|
public node: SVNode;
|
||||||
public target: SVNode;
|
public target: SVNode;
|
||||||
|
public label: string; //边的权值
|
||||||
public linkIndex: number;
|
public linkIndex: number;
|
||||||
|
|
||||||
public shadowG6Item: IEdge;
|
public shadowG6Item: IEdge;
|
||||||
@ -23,15 +24,19 @@ export class SVLink extends SVModel {
|
|||||||
node: SVNode,
|
node: SVNode,
|
||||||
target: SVNode,
|
target: SVNode,
|
||||||
index: number,
|
index: number,
|
||||||
options: LinkOption
|
options: LinkOption,
|
||||||
|
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;
|
||||||
this.nodeId = node.id;
|
this.nodeId = node.id;
|
||||||
this.targetId = target.id;
|
this.targetId = target.id;
|
||||||
this.linkIndex = index;
|
this.linkIndex = index;
|
||||||
|
this.label = label; //边的权值
|
||||||
|
|
||||||
node.links.outDegree.push(this);
|
node.links.outDegree.push(this);
|
||||||
target.links.inDegree.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) {
|
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 } }
|
||||||
|
: Util.objectClone<LinkLabelOption>(options.labelOptions || ({} as LinkLabelOption));
|
||||||
|
|
||||||
|
|
||||||
let label = this.target.sourceNode.freed ? 'freed' : '',
|
// let label = this.target.sourceNode.freed ? 'freed' : '',
|
||||||
labelCfg = this.target.sourceNode.freed
|
// labelCfg = this.target.sourceNode.freed
|
||||||
? { position: 'start', autoRotate: true, refY: 7, style: { fontSize: 11, opacity: 0.8 } }
|
// ? { 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));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
@ -62,7 +70,7 @@ export class SVLink extends SVModel {
|
|||||||
target: this.target.id,
|
target: this.target.id,
|
||||||
sourceAnchor,
|
sourceAnchor,
|
||||||
targetAnchor,
|
targetAnchor,
|
||||||
label,
|
label:this.label,
|
||||||
style: Util.objectClone<Style>(options.style),
|
style: Util.objectClone<Style>(options.style),
|
||||||
labelCfg,
|
labelCfg,
|
||||||
curveOffset: options.curveOffset,
|
curveOffset: options.curveOffset,
|
||||||
|
@ -169,8 +169,10 @@ export class ModelConstructor {
|
|||||||
linkNames = Object.keys(linkOptions);
|
linkNames = Object.keys(linkOptions);
|
||||||
|
|
||||||
linkNames.forEach(name => {
|
linkNames.forEach(name => {
|
||||||
|
|
||||||
for (let i = 0; i < nodes.length; i++) {
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
let node: SVNode = nodes[i],
|
let node: SVNode = nodes[i],
|
||||||
|
value,
|
||||||
sourceLinkData: sourceLinkData = node.sourceNode[name],
|
sourceLinkData: sourceLinkData = node.sourceNode[name],
|
||||||
targetNode: SVNode | SVNode[] = null,
|
targetNode: SVNode | SVNode[] = null,
|
||||||
link: SVLink = null;
|
link: SVLink = null;
|
||||||
@ -183,11 +185,18 @@ export class ModelConstructor {
|
|||||||
// ------------------- 将连接声明字段 sourceLinkData 从 id 变为 SVNode -------------------
|
// ------------------- 将连接声明字段 sourceLinkData 从 id 变为 SVNode -------------------
|
||||||
if (Array.isArray(sourceLinkData)) {
|
if (Array.isArray(sourceLinkData)) {
|
||||||
node[name] = sourceLinkData.map((item, index) => {
|
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);
|
targetNode = this.fetchTargetNodes(layoutGroupTable, node, item);
|
||||||
let isGeneralLink = ModelConstructor.isGeneralLink(sourceLinkData.toString());
|
let isGeneralLink = ModelConstructor.isGeneralLink(sourceLinkData.toString());
|
||||||
|
|
||||||
if (targetNode) {
|
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);
|
linkList.push(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +207,7 @@ export class ModelConstructor {
|
|||||||
let isGeneralLink = ModelConstructor.isGeneralLink(sourceLinkData.toString());
|
let isGeneralLink = ModelConstructor.isGeneralLink(sourceLinkData.toString());
|
||||||
|
|
||||||
if (targetNode) {
|
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);
|
linkList.push(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,7 +388,8 @@ export class ModelConstructor {
|
|||||||
node: SVNode,
|
node: SVNode,
|
||||||
target: SVNode,
|
target: SVNode,
|
||||||
index: number,
|
index: number,
|
||||||
options: LinkOption
|
options: LinkOption,
|
||||||
|
label: string
|
||||||
): SVLink {
|
): SVLink {
|
||||||
let id;
|
let id;
|
||||||
// 如果数据结构是图,则不需要index来区分是哪条边
|
// 如果数据结构是图,则不需要index来区分是哪条边
|
||||||
@ -388,7 +398,7 @@ export class ModelConstructor {
|
|||||||
} else {
|
} else {
|
||||||
id = `${linkName}{${node.id}-${target.id}}#${index}`;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (typeof linkTarget === 'number' || (typeof linkTarget === 'string' && !linkTarget.includes('#'))) {
|
if (typeof linkTarget === 'number' || (typeof linkTarget === 'string' && !linkTarget.includes('#'))) {
|
||||||
linkTarget = 'default#' + linkTarget;
|
linkTarget = 'default#' + linkTarget;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ export const Animations = {
|
|||||||
* @param animationConfig
|
* @param animationConfig
|
||||||
*/
|
*/
|
||||||
APPEND(G6Item: Item, animationConfig: animationConfig) {
|
APPEND(G6Item: Item, animationConfig: animationConfig) {
|
||||||
const type = G6Item.getType(),
|
const type = G6Item.getType(),
|
||||||
group = G6Item.getContainer(),
|
group = G6Item.getContainer(),
|
||||||
Mat3 = Util.mat3,
|
Mat3 = Util.mat3,
|
||||||
animateCfg = {
|
animateCfg = {
|
||||||
@ -27,12 +27,14 @@ export const Animations = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (type === 'node') {
|
if (type === 'node') {
|
||||||
let matrix = group.getMatrix(),
|
let matrix = group.getMatrix(),
|
||||||
targetMatrix = Mat3.clone(matrix);
|
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]);
|
Mat3.scale(targetMatrix, targetMatrix, [1, 1]);
|
||||||
|
|
||||||
|
// 让结点透明度从0到1
|
||||||
group.attr({ matrix, opacity: 0 });
|
group.attr({ matrix, opacity: 0 });
|
||||||
group.animate({ matrix: targetMatrix, opacity: 1 }, animateCfg);
|
group.animate({ matrix: targetMatrix, opacity: 1 }, animateCfg);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user