Skip to content

Commit f73be72

Browse files
DymoneLewisboyongjiong
authored andcommitted
feat: 折线边支持配置节点相邻第一个拐点位置&曲线边支持配置调整线拉伸长度
1 parent 4837a9a commit f73be72

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

examples/engine-browser-examples/src/pages/graph/index.tsx

+25-5
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ const data = {
8181
nodes: [
8282
{
8383
id: 'custom-node-1',
84-
rotate: 1.1722738811284763,
84+
// rotate: 1.1722738811284763,
8585
text: {
86-
x: 600,
87-
y: 200,
86+
x: 400,
87+
y: 400,
8888
value: 'node-1',
8989
draggable: true,
9090
},
9191
type: 'rect',
92-
x: 600,
93-
y: 200,
92+
x: 400,
93+
y: 400,
9494
properties: {
9595
width: 80,
9696
height: 120,
@@ -104,6 +104,26 @@ const data = {
104104
y: 94,
105105
},
106106
],
107+
edges: [
108+
{
109+
type: 'animation-edge',
110+
sourceNodeId: 'custom-node-1',
111+
targetNodeId: 'custom-node-2',
112+
properties: {
113+
// offset: 500,
114+
arrowType: 'empty',
115+
},
116+
},
117+
// {
118+
// type: 'polyline',
119+
// sourceNodeId: 'custom-node-1',
120+
// targetNodeId: 'custom-node-2',
121+
// properties: {
122+
// // offset: 10,
123+
// arrowType: 'empty',
124+
// },
125+
// }
126+
],
107127
}
108128

109129
export default function BasicNode() {

packages/core/src/model/edge/BezierEdgeModel.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assign, cloneDeep } from 'lodash-es'
1+
import { get, assign, cloneDeep } from 'lodash-es'
22
import { action, observable } from 'mobx'
33
import BaseEdgeModel from './BaseEdgeModel'
44
import { BaseNodeModel } from '../node'
@@ -21,7 +21,7 @@ export class BezierEdgeModel extends BaseEdgeModel {
2121
this.setAttributes()
2222
}
2323
initEdgeData(data: EdgeConfig): void {
24-
this.offset = 100
24+
this.offset = get(data, 'properties.offset', 100)
2525
super.initEdgeData(data)
2626
}
2727
getEdgeStyle() {

packages/core/src/model/edge/PolylineEdgeModel.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assign, cloneDeep } from 'lodash-es'
1+
import { get, assign, cloneDeep } from 'lodash-es'
22
import { observable, action } from 'mobx'
33
import { BaseEdgeModel } from '.'
44
import { BaseNodeModel, RectNodeModel, CircleNodeModel, Model } from '..'
@@ -34,7 +34,7 @@ export class PolylineEdgeModel extends BaseEdgeModel {
3434
@observable dbClickPosition?: Point
3535

3636
initEdgeData(data: LogicFlow.EdgeConfig): void {
37-
this.offset = 30
37+
this.offset = get(data, 'properties.offset', 30)
3838
if (data.pointsList) {
3939
this.pointsList = data.pointsList
4040
}

0 commit comments

Comments
 (0)