fix: bug 修复
This commit is contained in:
parent
97749ec35e
commit
2a09ca6be1
@ -8,15 +8,15 @@ SV.registerLayout('BinaryTree', {
|
||||
label: '[data]',
|
||||
style: {
|
||||
fill: '#b83b5e',
|
||||
stroke: "#333",
|
||||
cursor: 'pointer'
|
||||
}
|
||||
}
|
||||
stroke: '#333',
|
||||
cursor: 'pointer',
|
||||
},
|
||||
},
|
||||
},
|
||||
link: {
|
||||
child: {
|
||||
type: 'line',
|
||||
sourceAnchor: index => index === 0 ? 3 : 1,
|
||||
sourceAnchor: index => (index === 0 ? 3 : 1),
|
||||
targetAnchor: 0,
|
||||
style: {
|
||||
stroke: '#333',
|
||||
@ -25,10 +25,10 @@ SV.registerLayout('BinaryTree', {
|
||||
endArrow: 'default',
|
||||
startArrow: {
|
||||
path: G6.Arrow.circle(2, -1),
|
||||
fill: '#333'
|
||||
}
|
||||
}
|
||||
}
|
||||
fill: '#333',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
marker: {
|
||||
external: {
|
||||
@ -36,22 +36,22 @@ SV.registerLayout('BinaryTree', {
|
||||
anchor: 0,
|
||||
offset: 14,
|
||||
style: {
|
||||
fill: '#f08a5d'
|
||||
fill: '#f08a5d',
|
||||
},
|
||||
labelOptions: {
|
||||
style: {
|
||||
fill: '#000099'
|
||||
}
|
||||
}
|
||||
}
|
||||
fill: '#000099',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
layout: {
|
||||
xInterval: 40,
|
||||
yInterval: 40
|
||||
yInterval: 40,
|
||||
},
|
||||
behavior: {
|
||||
// dragNode: false
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@ -67,40 +67,25 @@ SV.registerLayout('BinaryTree', {
|
||||
let bound = node.getBound(),
|
||||
width = bound.width,
|
||||
height = bound.height,
|
||||
group = new Group(node);
|
||||
group = new Group(node),
|
||||
leftGroup = null,
|
||||
rightGroup = null;
|
||||
|
||||
if (node.visited) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (parent) {
|
||||
node.set('y', parent.get('y') + layoutOptions.yInterval + height);
|
||||
|
||||
// 左节点
|
||||
if (index === 0) {
|
||||
node.set('x', parent.get('x') - layoutOptions.xInterval / 2 - width / 2);
|
||||
if (node.child && node.child[0]) {
|
||||
leftGroup = this.layoutItem(node.child[0], node, 0, layoutOptions);
|
||||
}
|
||||
|
||||
// 右结点
|
||||
if (index === 1) {
|
||||
node.set('x', parent.get('x') + layoutOptions.xInterval / 2 + width / 2);
|
||||
if (node.child && node.child[1]) {
|
||||
rightGroup = this.layoutItem(node.child[1], node, 1, layoutOptions);
|
||||
}
|
||||
}
|
||||
|
||||
node.visited = true;
|
||||
|
||||
if (node.child && (node.child[0] || node.child[1])) {
|
||||
let leftChild = node.child[0],
|
||||
rightChild = node.child[1],
|
||||
leftGroup = this.layoutItem(leftChild, node, 0, layoutOptions),
|
||||
rightGroup = this.layoutItem(rightChild, node, 1, layoutOptions),
|
||||
intersection = null,
|
||||
move = 0;
|
||||
|
||||
// 处理左右子树相交问题
|
||||
if (leftGroup && rightGroup) {
|
||||
intersection = Bound.intersect(leftGroup.getBound(), rightGroup.getBound());
|
||||
let intersection = Bound.intersect(leftGroup.getBound(), rightGroup.getBound()),
|
||||
move = 0;
|
||||
|
||||
if (intersection && intersection.width > 0) {
|
||||
@ -110,13 +95,28 @@ SV.registerLayout('BinaryTree', {
|
||||
}
|
||||
}
|
||||
|
||||
if (leftGroup) {
|
||||
let leftBound = leftGroup.getBound();
|
||||
|
||||
node.set('y', leftBound.y - layoutOptions.yInterval - height);
|
||||
node.set('x', leftBound.x + leftBound.width + layoutOptions.xInterval / 2 - width);
|
||||
}
|
||||
|
||||
if(rightGroup) {
|
||||
let rightBound = rightGroup.getBound();
|
||||
|
||||
node.set('y', rightBound.y - layoutOptions.yInterval - height);
|
||||
node.set('x', rightBound.x - layoutOptions.xInterval / 2 - width);
|
||||
}
|
||||
|
||||
node.visited = true;
|
||||
|
||||
if (leftGroup) {
|
||||
group.add(leftGroup);
|
||||
}
|
||||
|
||||
if (rightGroup) {
|
||||
group.add(rightGroup)
|
||||
}
|
||||
group.add(rightGroup);
|
||||
}
|
||||
|
||||
return group;
|
||||
@ -130,20 +130,16 @@ SV.registerLayout('BinaryTree', {
|
||||
layout(elements, layoutOptions) {
|
||||
let root = elements[0];
|
||||
this.layoutItem(root, null, -1, layoutOptions);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[{
|
||||
"id": 6385328,
|
||||
"data": "",
|
||||
"external": [
|
||||
"L"
|
||||
],
|
||||
"root": true,
|
||||
"after": null,
|
||||
"next": null
|
||||
}]
|
||||
[
|
||||
{
|
||||
id: 6385328,
|
||||
data: '',
|
||||
external: ['L'],
|
||||
root: true,
|
||||
after: null,
|
||||
next: null,
|
||||
},
|
||||
];
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
@ -94,144 +93,105 @@
|
||||
},
|
||||
});
|
||||
|
||||
let data = [{
|
||||
"BinaryTree0": {
|
||||
"data": [{
|
||||
"external": [
|
||||
"T"
|
||||
],
|
||||
"child": [
|
||||
"0x616060",
|
||||
"0x615f40"
|
||||
],
|
||||
"id": "0x615f10",
|
||||
"name": "T",
|
||||
"data": "F",
|
||||
"root": true,
|
||||
"type": "default"
|
||||
}, {
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x616090"
|
||||
],
|
||||
"id": "0x616060",
|
||||
"name": "T->lchild",
|
||||
"data": "A",
|
||||
"type": "default"
|
||||
}, {
|
||||
"child": [
|
||||
"0x6160c0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0x616090",
|
||||
"name": "(T->lchild)->rchild",
|
||||
"data": "E",
|
||||
"type": "default"
|
||||
}, {
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0x6160c0",
|
||||
"name": "((T->lchild)->rchild)->lchild",
|
||||
"data": "D",
|
||||
"type": "default"
|
||||
}, {
|
||||
"child": [
|
||||
"0x615f70",
|
||||
"0x615fd0"
|
||||
],
|
||||
"id": "0x615f40",
|
||||
"name": "T->rchild",
|
||||
"data": "U",
|
||||
"type": "default"
|
||||
}, {
|
||||
"child": [
|
||||
"0x615fa0",
|
||||
"0x616000"
|
||||
],
|
||||
"id": "0x615f70",
|
||||
"name": "(T->rchild)->lchild",
|
||||
"data": "S",
|
||||
"type": "default"
|
||||
}, {
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0x615fa0",
|
||||
"name": "((T->rchild)->lchild)->lchild",
|
||||
"data": "R",
|
||||
"type": "default"
|
||||
}, {
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0x616000",
|
||||
"name": "((T->rchild)->lchild)->rchild",
|
||||
"data": "T",
|
||||
"type": "default"
|
||||
}, {
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x616030"
|
||||
],
|
||||
"id": "0x615fd0",
|
||||
"name": "(T->rchild)->rchild",
|
||||
"data": "V",
|
||||
"type": "default"
|
||||
}, {
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0x616030",
|
||||
"name": "((T->rchild)->rchild)->rchild",
|
||||
"data": "X",
|
||||
"type": "default"
|
||||
}],
|
||||
"layouter": "BinaryTree"
|
||||
let data = [
|
||||
{
|
||||
BinaryTree0: {
|
||||
data: [
|
||||
{
|
||||
external: ['T', 'p'],
|
||||
child: ['0x615f40', '0x0'],
|
||||
id: '0x615f10',
|
||||
name: 'T',
|
||||
data: 'W',
|
||||
root: true,
|
||||
type: 'default',
|
||||
},
|
||||
"isEnterFunction": true
|
||||
}, {
|
||||
"BinaryTree0": {
|
||||
"data": [{
|
||||
"external": [
|
||||
"T"
|
||||
],
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x616090"
|
||||
],
|
||||
"id": "0x616060",
|
||||
"name": "T",
|
||||
"data": "A",
|
||||
"root": true,
|
||||
"type": "default"
|
||||
}, {
|
||||
"child": [
|
||||
"0x6160c0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0x616090",
|
||||
"name": "T->rchild",
|
||||
"data": "E",
|
||||
"type": "default"
|
||||
}, {
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0x6160c0",
|
||||
"name": "(T->rchild)->lchild",
|
||||
"data": "D",
|
||||
"type": "default"
|
||||
}],
|
||||
"layouter": "BinaryTree"
|
||||
{
|
||||
child: ['0x615f70', '0x615fa0'],
|
||||
id: '0x615f40',
|
||||
name: 'T->lchild',
|
||||
data: 'Q',
|
||||
type: 'default',
|
||||
},
|
||||
"isEnterFunction": true
|
||||
}];
|
||||
{
|
||||
child: ['0x0', '0x615fd0'],
|
||||
id: '0x615f70',
|
||||
name: '(T->lchild)->lchild',
|
||||
data: 'A',
|
||||
type: 'default',
|
||||
},
|
||||
{
|
||||
child: ['0x0', '0x0'],
|
||||
id: '0x615fd0',
|
||||
name: '((T->lchild)->lchild)->rchild',
|
||||
data: 'D',
|
||||
type: 'default',
|
||||
},
|
||||
{
|
||||
child: ['0x616000', '0x616030'],
|
||||
id: '0x615fa0',
|
||||
name: '(T->lchild)->rchild',
|
||||
data: 'U',
|
||||
type: 'default',
|
||||
},
|
||||
{
|
||||
child: ['0x0', '0x0'],
|
||||
id: '0x616000',
|
||||
name: '((T->lchild)->rchild)->lchild',
|
||||
data: 'S',
|
||||
type: 'default',
|
||||
},
|
||||
{
|
||||
child: ['0x0', '0x0'],
|
||||
id: '0x616030',
|
||||
name: '((T->lchild)->rchild)->rchild',
|
||||
data: 'V',
|
||||
type: 'default',
|
||||
},
|
||||
],
|
||||
layouter: 'BinaryTree',
|
||||
},
|
||||
isEnterFunction: false,
|
||||
},
|
||||
{
|
||||
BinaryTree0: {
|
||||
data: [
|
||||
{
|
||||
external: ['T', 'p'],
|
||||
child: ['0x615f40', '0x0'],
|
||||
id: '0x615f10',
|
||||
name: 'T',
|
||||
data: 'W',
|
||||
root: true,
|
||||
type: 'default',
|
||||
},
|
||||
{
|
||||
child: ['0x615f70', '0x615fa0'],
|
||||
id: '0x615f40',
|
||||
name: 'T->lchild',
|
||||
data: 'Q',
|
||||
type: 'default',
|
||||
},
|
||||
{
|
||||
child: ['0x0', '0x615fd0'],
|
||||
id: '0x615f70',
|
||||
name: '(T->lchild)->lchild',
|
||||
data: 'A',
|
||||
type: 'default',
|
||||
},
|
||||
{
|
||||
child: ['0x0', '0x0'],
|
||||
id: '0x615fd0',
|
||||
name: '((T->lchild)->lchild)->rchild',
|
||||
data: 'D',
|
||||
type: 'default',
|
||||
}
|
||||
],
|
||||
layouter: 'BinaryTree',
|
||||
},
|
||||
isEnterFunction: false,
|
||||
},
|
||||
];
|
||||
|
||||
let dataIndex = 0,
|
||||
curData = data[dataIndex];
|
||||
@ -287,5 +247,4 @@
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -1,8 +1,8 @@
|
||||
|
||||
import { Util } from '../Common/util';
|
||||
|
||||
|
||||
export default Util.registerShape('binary-tree-node', {
|
||||
export default Util.registerShape(
|
||||
'binary-tree-node',
|
||||
{
|
||||
draw(cfg, group) {
|
||||
cfg.size = cfg.size;
|
||||
|
||||
@ -17,9 +17,9 @@ export default Util.registerShape('binary-tree-node', {
|
||||
height: height,
|
||||
stroke: cfg.style.stroke || '#333',
|
||||
cursor: cfg.style.cursor,
|
||||
fill: cfg.style.backgroundFill || '#eee'
|
||||
fill: cfg.style.backgroundFill || '#eee',
|
||||
},
|
||||
name: 'wrapper'
|
||||
name: 'wrapper',
|
||||
});
|
||||
|
||||
group.addShape('rect', {
|
||||
@ -30,16 +30,15 @@ export default Util.registerShape('binary-tree-node', {
|
||||
height: height,
|
||||
fill: cfg.style.fill,
|
||||
stroke: cfg.style.stroke || '#333',
|
||||
cursor: cfg.style.cursor
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'mid',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
|
||||
const style = (cfg.labelCfg && cfg.labelCfg.style) || {};
|
||||
|
||||
if (cfg.label) {
|
||||
|
||||
group.addShape('text', {
|
||||
attrs: {
|
||||
x: width, // 居中
|
||||
@ -49,15 +48,20 @@ export default Util.registerShape('binary-tree-node', {
|
||||
text: cfg.label,
|
||||
fill: style.fill || '#000',
|
||||
fontSize: style.fontSize || 16,
|
||||
cursor: cfg.style.cursor
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
|
||||
const isLeftEmpty =
|
||||
!cfg.child || cfg.child[0] === undefined || cfg.child[0] === undefined || cfg.child[0] == '0x0',
|
||||
isRightEmpty =
|
||||
!cfg.child || cfg.child[1] === undefined || cfg.child[1] === undefined || cfg.child[1] == '0x0';
|
||||
|
||||
//节点没有左孩子节点时
|
||||
if(cfg.child[0] == "0x0"){
|
||||
if (isLeftEmpty) {
|
||||
group.addShape('text', {
|
||||
attrs: {
|
||||
x: width * (5 / 8),
|
||||
@ -66,15 +70,15 @@ export default Util.registerShape('binary-tree-node', {
|
||||
textBaseline: 'middle',
|
||||
text: '^',
|
||||
fill: style.fill || '#000',
|
||||
fontSize: 18,
|
||||
fontSize: 16,
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
//节点没有右孩子节点时
|
||||
if(cfg.child[1] == "0x0"){
|
||||
if (isRightEmpty) {
|
||||
group.addShape('text', {
|
||||
attrs: {
|
||||
x: width * (11 / 8),
|
||||
@ -83,11 +87,11 @@ export default Util.registerShape('binary-tree-node', {
|
||||
textBaseline: 'middle',
|
||||
text: '^',
|
||||
fill: style.fill || '#000',
|
||||
fontSize: 18,
|
||||
fontSize: 16,
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -99,7 +103,9 @@ export default Util.registerShape('binary-tree-node', {
|
||||
[0.5, 0],
|
||||
[0.875, 0.5],
|
||||
[0.5, 1],
|
||||
[0.125, 0.5]
|
||||
[0.125, 0.5],
|
||||
];
|
||||
},
|
||||
}, 'rect');
|
||||
},
|
||||
'rect'
|
||||
);
|
||||
|
||||
@ -1,21 +1,14 @@
|
||||
import G6 from "@antv/g6";
|
||||
import { Util } from "../Common/util";
|
||||
|
||||
|
||||
|
||||
import G6 from '@antv/g6';
|
||||
import { Util } from '../Common/util';
|
||||
|
||||
export default function rotate(shape, angle, transform) {
|
||||
const matrix1 = shape.getMatrix();
|
||||
const newMatrix1 = transform(matrix1, [
|
||||
['r', angle],
|
||||
]);
|
||||
const newMatrix1 = transform(matrix1, [['r', angle]]);
|
||||
shape.setMatrix(newMatrix1);
|
||||
}
|
||||
function translate(shape, x, y, transform) {
|
||||
const matrix1 = shape.getMatrix();
|
||||
const newMatrix1 = transform(matrix1, [
|
||||
['t', x, y],
|
||||
]);
|
||||
const newMatrix1 = transform(matrix1, [['t', x, y]]);
|
||||
shape.setMatrix(newMatrix1);
|
||||
}
|
||||
function culcuRotate(angle, R) {
|
||||
@ -25,10 +18,8 @@ function culcuRotate(angle, R) {
|
||||
return {
|
||||
offsetX,
|
||||
offsetY,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Util.registerShape('clen-queue-pointer', {
|
||||
draw(cfg, group) {
|
||||
@ -44,10 +35,10 @@ Util.registerShape('clen-queue-pointer', {
|
||||
fill: cfg.style.fill,
|
||||
// matrix: cfg.style.matrix
|
||||
},
|
||||
name: 'pointer-path'
|
||||
name: 'pointer-path',
|
||||
});
|
||||
|
||||
const angle = index * Math.PI * 2 / len;
|
||||
const angle = (index * Math.PI * 2) / len;
|
||||
if (cfg.label) {
|
||||
const style = (cfg.labelCfg && cfg.labelCfg.style) || {};
|
||||
|
||||
@ -59,15 +50,15 @@ Util.registerShape('clen-queue-pointer', {
|
||||
height: 0,
|
||||
text: cfg.label,
|
||||
fill: null,
|
||||
radius: 2
|
||||
radius: 2,
|
||||
},
|
||||
name: 'bgRect'
|
||||
name: 'bgRect',
|
||||
});
|
||||
|
||||
let label = cfg.label as string;
|
||||
|
||||
let pointerText = label.split('-')[0];
|
||||
let y = pointerText=="front"?30:15;
|
||||
let y = pointerText == 'front' ? 30 : 15;
|
||||
const text = group.addShape('text', {
|
||||
attrs: {
|
||||
x: culcuRotate(Math.PI / 2 - angle, y).offsetX,
|
||||
@ -78,9 +69,9 @@ Util.registerShape('clen-queue-pointer', {
|
||||
textBaseline: 'middle',
|
||||
text: pointerText,
|
||||
fill: style.fill || '#999',
|
||||
fontSize: style.fontSize || 16
|
||||
fontSize: style.fontSize || 16,
|
||||
},
|
||||
name: 'pointer-text-shape'
|
||||
name: 'pointer-text-shape',
|
||||
});
|
||||
|
||||
// rotate(text, angle, G6.Util.transform);
|
||||
@ -90,8 +81,6 @@ Util.registerShape('clen-queue-pointer', {
|
||||
translate(keyShape, 0, -75, G6.Util.transform);
|
||||
|
||||
return keyShape;
|
||||
|
||||
|
||||
},
|
||||
|
||||
getPath(cfg) {
|
||||
@ -104,9 +93,9 @@ Util.registerShape('clen-queue-pointer', {
|
||||
['M', 0, 0],
|
||||
['L', -width / 2, 0],
|
||||
['L', -width / 2, -height],
|
||||
['L', -width / 2 - (arrowWidth / 2), -height],
|
||||
['L', -width / 2 - arrowWidth / 2, -height],
|
||||
['L', 0, -height - arrowHeight],
|
||||
['L', width / 2 + (arrowWidth / 2), -height],
|
||||
['L', width / 2 + arrowWidth / 2, -height],
|
||||
['L', width / 2, -height],
|
||||
['L', width / 2, 0],
|
||||
['Z'],
|
||||
@ -114,7 +103,4 @@ Util.registerShape('clen-queue-pointer', {
|
||||
|
||||
return path;
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -6,11 +6,11 @@
|
||||
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
* @FilePath: \水功能c:\Users\13127\Desktop\最近的前端文件\可视化0126\StructV2\src\RegisteredShape\linkListNode.ts
|
||||
*/
|
||||
import { Util } from "../Common/util";
|
||||
import { Util } from '../Common/util';
|
||||
|
||||
|
||||
|
||||
export default Util.registerShape('link-list-node', {
|
||||
export default Util.registerShape(
|
||||
'link-list-node',
|
||||
{
|
||||
draw(cfg, group) {
|
||||
cfg.size = cfg.size || [30, 10];
|
||||
|
||||
@ -25,9 +25,9 @@ export default Util.registerShape('link-list-node', {
|
||||
height: height,
|
||||
stroke: cfg.style.stroke || '#333',
|
||||
fill: cfg.style.backgroundFill || '#eee',
|
||||
cursor: cfg.style.cursor
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'wrapper'
|
||||
name: 'wrapper',
|
||||
});
|
||||
|
||||
group.addShape('rect', {
|
||||
@ -38,10 +38,10 @@ export default Util.registerShape('link-list-node', {
|
||||
height: height,
|
||||
fill: cfg.style.fill,
|
||||
stroke: cfg.style.stroke || '#333',
|
||||
cursor: cfg.style.cursor
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'main-rect',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
|
||||
const style = (cfg.labelCfg && cfg.labelCfg.style) || {};
|
||||
@ -55,10 +55,10 @@ export default Util.registerShape('link-list-node', {
|
||||
textBaseline: 'middle',
|
||||
text: cfg.label,
|
||||
fill: style.fill || '#000',
|
||||
fontSize: style.fontSize || 16
|
||||
fontSize: style.fontSize || 16,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -72,11 +72,11 @@ export default Util.registerShape('link-list-node', {
|
||||
textBaseline: 'middle',
|
||||
text: '^',
|
||||
fill: style.fill || '#000',
|
||||
fontSize: 18,
|
||||
fontSize: 16,
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -92,7 +92,9 @@ export default Util.registerShape('link-list-node', {
|
||||
[5 / 6, 1],
|
||||
[0.5, 1],
|
||||
[0, 0.5],
|
||||
[1 / 3, 1]
|
||||
[1 / 3, 1],
|
||||
];
|
||||
}
|
||||
}, 'rect');
|
||||
},
|
||||
},
|
||||
'rect'
|
||||
);
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
import { Util } from '../Common/util';
|
||||
|
||||
|
||||
export default Util.registerShape('pointer', {
|
||||
draw(cfg, group) {
|
||||
const keyShape = group.addShape('path', {
|
||||
attrs: {
|
||||
path: this.getPath(cfg),
|
||||
fill: cfg.style.fill,
|
||||
matrix: cfg.style.matrix
|
||||
matrix: cfg.style.matrix,
|
||||
},
|
||||
name: 'pointer-path'
|
||||
name: 'pointer-path',
|
||||
});
|
||||
|
||||
if (cfg.label) {
|
||||
@ -21,9 +20,9 @@ export default Util.registerShape('pointer', {
|
||||
y: 0,
|
||||
text: cfg.label,
|
||||
fill: null,
|
||||
radius: 2
|
||||
radius: 2,
|
||||
},
|
||||
name: 'bgRect'
|
||||
name: 'bgRect',
|
||||
});
|
||||
|
||||
const text = group.addShape('text', {
|
||||
@ -34,16 +33,16 @@ export default Util.registerShape('pointer', {
|
||||
textBaseline: 'middle',
|
||||
text: cfg.label,
|
||||
fill: labelStyle.fill || '#999',
|
||||
fontSize: labelStyle.fontSize || 16
|
||||
fontSize: labelStyle.fontSize || 16,
|
||||
},
|
||||
name: 'pointer-text-shape'
|
||||
name: 'pointer-text-shape',
|
||||
});
|
||||
|
||||
const { width: textWidth, height: textHeight } = text.getBBox();
|
||||
const { width: pointerWidth, height: pointerHeight } = keyShape.getBBox();
|
||||
bgRect.attr({
|
||||
width: textWidth + pointerWidth + 6,
|
||||
height: textHeight + pointerHeight + 6
|
||||
height: textHeight + pointerHeight + 6,
|
||||
});
|
||||
|
||||
// 旋转文字
|
||||
@ -54,12 +53,12 @@ export default Util.registerShape('pointer', {
|
||||
|
||||
text.attr({
|
||||
x: textX,
|
||||
y: textY
|
||||
y: textY,
|
||||
});
|
||||
|
||||
bgRect.attr({
|
||||
x: textX - textWidth / 2 - 3,
|
||||
y: textY - textHeight / 2 - 3
|
||||
y: textY - textHeight / 2 - 3,
|
||||
});
|
||||
}
|
||||
return bgRect;
|
||||
@ -76,15 +75,15 @@ export default Util.registerShape('pointer', {
|
||||
|
||||
const path = [
|
||||
['M', 0, 0],
|
||||
['L', -width / 2 - (arrowWidth / 2), -arrowHeight],
|
||||
['L', -width / 2 - arrowWidth / 2, -arrowHeight],
|
||||
['L', -width / 2, -arrowHeight],
|
||||
['L', -width / 2, -height],
|
||||
['L', width / 2, -height],
|
||||
['L', width / 2, -arrowHeight],
|
||||
['L', width / 2 + (arrowWidth / 2), -arrowHeight],
|
||||
['L', width / 2 + arrowWidth / 2, -arrowHeight],
|
||||
['Z'],
|
||||
];
|
||||
|
||||
return path;
|
||||
}
|
||||
},
|
||||
});
|
||||
@ -8,8 +8,6 @@
|
||||
*/
|
||||
import { registerNode } from '@antv/g6';
|
||||
|
||||
|
||||
|
||||
export default registerNode('three-cell', {
|
||||
draw(cfg, group) {
|
||||
cfg.size = cfg.size || [30, 10];
|
||||
@ -24,9 +22,9 @@ export default registerNode('three-cell', {
|
||||
width: width,
|
||||
height: height,
|
||||
stroke: cfg.style.stroke,
|
||||
fill: cfg.style.backgroundFill || '#eee'
|
||||
fill: cfg.style.backgroundFill || '#eee',
|
||||
},
|
||||
name: 'wrapper'
|
||||
name: 'wrapper',
|
||||
});
|
||||
|
||||
group.addShape('rect', {
|
||||
@ -36,10 +34,10 @@ export default registerNode('three-cell', {
|
||||
width: width / 3,
|
||||
height: height,
|
||||
fill: cfg.style.fill,
|
||||
stroke: cfg.style.stroke
|
||||
stroke: cfg.style.stroke,
|
||||
},
|
||||
name: 'left-rect',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
|
||||
group.addShape('rect', {
|
||||
@ -49,10 +47,10 @@ export default registerNode('three-cell', {
|
||||
width: width / 3,
|
||||
height: height,
|
||||
fill: cfg.style.fill,
|
||||
stroke: cfg.style.stroke
|
||||
stroke: cfg.style.stroke,
|
||||
},
|
||||
name: 'middle-rect',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
|
||||
const style = (cfg.labelCfg && cfg.labelCfg.style) || {};
|
||||
@ -72,7 +70,7 @@ export default registerNode('three-cell', {
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
|
||||
group.addShape('text', {
|
||||
@ -88,7 +86,7 @@ export default registerNode('three-cell', {
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
|
||||
group.addShape('text', {
|
||||
@ -104,7 +102,7 @@ export default registerNode('three-cell', {
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -123,7 +121,7 @@ export default registerNode('three-cell', {
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
//节点文字(数组形式)
|
||||
@ -140,7 +138,7 @@ export default registerNode('three-cell', {
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
|
||||
group.addShape('text', {
|
||||
@ -155,7 +153,7 @@ export default registerNode('three-cell', {
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -169,15 +167,14 @@ export default registerNode('three-cell', {
|
||||
textBaseline: 'middle',
|
||||
text: '^',
|
||||
fill: style.fill || '#000',
|
||||
fontSize: 25,
|
||||
fontSize: 22,
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return wrapperRect;
|
||||
},
|
||||
|
||||
@ -186,7 +183,7 @@ export default registerNode('three-cell', {
|
||||
[0.5, 0],
|
||||
[5 / 6, 0.5],
|
||||
[0.5, 1],
|
||||
[0, 0.5]
|
||||
[0, 0.5],
|
||||
];
|
||||
}
|
||||
},
|
||||
});
|
||||
@ -1,7 +1,8 @@
|
||||
import { Util } from '../Common/util';
|
||||
|
||||
|
||||
export default Util.registerShape('tri-tree-node', {
|
||||
export default Util.registerShape(
|
||||
'tri-tree-node',
|
||||
{
|
||||
draw(cfg, group) {
|
||||
cfg.size = cfg.size;
|
||||
|
||||
@ -16,9 +17,9 @@ export default Util.registerShape('tri-tree-node', {
|
||||
height: height,
|
||||
stroke: cfg.style.stroke || '#333',
|
||||
cursor: cfg.style.cursor,
|
||||
fill: cfg.style.backgroundFill || '#eee'
|
||||
fill: cfg.style.backgroundFill || '#eee',
|
||||
},
|
||||
name: 'wrapper'
|
||||
name: 'wrapper',
|
||||
});
|
||||
|
||||
group.addShape('rect', {
|
||||
@ -29,10 +30,10 @@ export default Util.registerShape('tri-tree-node', {
|
||||
height: height / 4,
|
||||
fill: '#eee',
|
||||
stroke: cfg.style.stroke || '#333',
|
||||
cursor: cfg.style.cursor
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'top',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
|
||||
group.addShape('rect', {
|
||||
@ -40,13 +41,13 @@ export default Util.registerShape('tri-tree-node', {
|
||||
x: width / 4 + width / 2,
|
||||
y: height / 2 + height / 4,
|
||||
width: width / 2,
|
||||
height: height / 4 * 3,
|
||||
height: (height / 4) * 3,
|
||||
fill: cfg.color || cfg.style.fill,
|
||||
stroke: cfg.style.stroke || '#333',
|
||||
cursor: cfg.style.cursor
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'bottom',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
|
||||
if (cfg.label) {
|
||||
@ -60,10 +61,10 @@ export default Util.registerShape('tri-tree-node', {
|
||||
text: cfg.label,
|
||||
fill: style.fill || '#000',
|
||||
fontSize: style.fontSize || 16,
|
||||
cursor: cfg.style.cursor
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -72,16 +73,16 @@ export default Util.registerShape('tri-tree-node', {
|
||||
group.addShape('text', {
|
||||
attrs: {
|
||||
x: width, // 居中
|
||||
y: height / 4 * 3,
|
||||
y: (height / 4) * 3,
|
||||
textAlign: 'center',
|
||||
textBaseline: 'middle',
|
||||
text: "^",
|
||||
text: '^',
|
||||
fill: style.fill || '#000',
|
||||
fontSize: style.fontSize || 14,
|
||||
cursor: cfg.style.cursor
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'parent',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -94,7 +95,9 @@ export default Util.registerShape('tri-tree-node', {
|
||||
[0.875, 0.5],
|
||||
[0.5, 1],
|
||||
[0.5, 0],
|
||||
[0.5, 0.125]
|
||||
[0.5, 0.125],
|
||||
];
|
||||
},
|
||||
}, 'rect');
|
||||
},
|
||||
'rect'
|
||||
);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { Util } from '../Common/util';
|
||||
|
||||
|
||||
|
||||
export default Util.registerShape('two-cell-node', {
|
||||
export default Util.registerShape(
|
||||
'two-cell-node',
|
||||
{
|
||||
draw(cfg, group) {
|
||||
cfg.size = cfg.size || [30, 10];
|
||||
|
||||
@ -16,9 +16,9 @@ export default Util.registerShape('two-cell-node', {
|
||||
width: width,
|
||||
height: height,
|
||||
stroke: cfg.style.stroke,
|
||||
fill: cfg.style.backgroundFill || '#eee'
|
||||
fill: cfg.style.backgroundFill || '#eee',
|
||||
},
|
||||
name: 'wrapper'
|
||||
name: 'wrapper',
|
||||
});
|
||||
|
||||
group.addShape('rect', {
|
||||
@ -28,17 +28,18 @@ export default Util.registerShape('two-cell-node', {
|
||||
width: width / 2,
|
||||
height: height,
|
||||
fill: cfg.style.fill,
|
||||
stroke: cfg.style.stroke
|
||||
stroke: cfg.style.stroke,
|
||||
},
|
||||
name: 'left-rect',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
|
||||
const style = (cfg.labelCfg && cfg.labelCfg.style) || {};
|
||||
|
||||
if (cfg.label) {
|
||||
if (Array.isArray(cfg.label)) {
|
||||
let tag = cfg.label[0], data = cfg.label[1];
|
||||
let tag = cfg.label[0],
|
||||
data = cfg.label[1];
|
||||
|
||||
group.addShape('text', {
|
||||
attrs: {
|
||||
@ -52,7 +53,7 @@ export default Util.registerShape('two-cell-node', {
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
|
||||
group.addShape('text', {
|
||||
@ -67,10 +68,9 @@ export default Util.registerShape('two-cell-node', {
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
group.addShape('text', {
|
||||
attrs: {
|
||||
x: width * (3 / 4),
|
||||
@ -83,7 +83,7 @@ export default Util.registerShape('two-cell-node', {
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -102,7 +102,7 @@ export default Util.registerShape('two-cell-node', {
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ export default Util.registerShape('two-cell-node', {
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -132,7 +132,9 @@ export default Util.registerShape('two-cell-node', {
|
||||
[0.5, 0],
|
||||
[3 / 4, 0.5],
|
||||
[0.5, 1],
|
||||
[0, 0.5]
|
||||
[0, 0.5],
|
||||
];
|
||||
}
|
||||
}, 'rect');
|
||||
},
|
||||
},
|
||||
'rect'
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user