Skip to content

Commit 4cb1bca

Browse files
committed
feat(core): Add stroke-dasharray vlaue to outline of node & edge
1. Add stroke-dasharray vlaue to outline of node & edge 2. This close #12
1 parent ba620cc commit 4cb1bca

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

docs/guide/advance/theme.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ lf.setTheme({
9999
|strokeOpacity|number|边框透明度|1|
100100
|opacity|number|整体透明度|1|
101101
|outlineColor|color|hover外边框颜色|1|
102+
|outlineStrokeDashArray|string|控制用来描外边框的点划线的图案范式, 设置为空是为实线|'3,3'|
102103
<details>
103104
<summary>点击展开查看矩形样式设置</summary>
104105

@@ -115,6 +116,7 @@ lf.setTheme({
115116
strokeOpacity: 1,
116117
opacity: 1,
117118
outlineColor: '#000000',
119+
outlineStrokeDashArray: '3,3',
118120
},
119121
})
120122
```
@@ -132,6 +134,7 @@ lf.setTheme({
132134
|strokeOpacity|number|边框透明度|1|
133135
|opacity|number|整体透明度|1|
134136
|outlineColor|color|hover外边框颜色|1|
137+
|outlineStrokeDashArray|string|控制用来描外边框的点划线的图案范式, 设置为空是为实线|'3,3'|
135138
<details>
136139
<summary>点击展开查看圆形样式设置</summary>
137140

@@ -146,6 +149,7 @@ lf.setTheme({
146149
strokeOpacity: 1,
147150
opacity: 1,
148151
outlineColor: '#000000',
152+
outlineStrokeDashArray: '3,3',
149153
},
150154
})
151155
```
@@ -164,6 +168,7 @@ lf.setTheme({
164168
|strokeOpacity|number|边框透明度|1|
165169
|opacity|number|整体透明度|1|
166170
|outlineColor|color|hover外边框颜色|1|
171+
|outlineStrokeDashArray|string|控制用来描外边框的点划线的图案范式, 设置为空是为实线|'3,3'|
167172
<details>
168173
<summary>点击展开查看椭圆样式设置</summary>
169174

@@ -179,6 +184,7 @@ lf.setTheme({
179184
strokeOpacity: 1,
180185
opacity: 1,
181186
outlineColor: '#000000',
187+
outlineStrokeDashArray: '3,3',
182188
},
183189
})
184190
```
@@ -242,6 +248,7 @@ lf.setTheme({
242248
|strokeOpacity|number|边框透明度|1|
243249
|opacity|number|整体透明度|1|
244250
|outlineColor|color|hover外边框颜色|1|
251+
|outlineStrokeDashArray|string|控制用来描外边框的点划线的图案范式, 设置为空是为实线|'3,3'|
245252
<details>
246253
<summary>点击展开查看多边形样式设置</summary>
247254

@@ -255,6 +262,7 @@ lf.setTheme({
255262
strokeOpacity: 1,
256263
opacity: 1,
257264
outlineColor: '#000000',
265+
outlineStrokeDashArray: '3,3',
258266
},
259267
})
260268
```
@@ -272,6 +280,7 @@ lf.setTheme({
272280
|strokeOpacity|number|边框透明度|1|
273281
|opacity|number|整体透明度|1|
274282
|outlineColor|color|外边框颜色|#000000|
283+
|outlineStrokeDashArray|string|控制用来描外边框的点划线的图案范式, 设置为空是为实线|'3,3'|
275284
<details>
276285
<summary>点击展开查看锚点样式设置</summary>
277286

@@ -285,6 +294,7 @@ lf.setTheme({
285294
strokeOpacity: 1,
286295
opacity: 1,
287296
outlineColor: '#000000',
297+
outlineStrokeDashArray: '3,3',
288298
},
289299
})
290300
```
@@ -350,6 +360,7 @@ lf.setTheme({
350360
|hoverStroke|color|连线hover颜色|#000000|
351361
|selectedStroke|color|连线选中颜色|#000000|
352362
|outlineColor|color|外边框颜色|#000000|
363+
|outlineStrokeDashArray|string|控制用来描外边框的点划线的图案范式, 设置为空是为实线|'3,3'|
353364
<details>
354365
<summary>点击展开查看直线样式设置</summary>
355366

@@ -361,6 +372,8 @@ lf.setTheme({
361372
hoverStroke: '#000000',
362373
selectedStroke: '#000000',
363374
selectedShadow: true,
375+
outlineColor: '#000000',
376+
outlineStrokeDashArray: '3,3',
364377
},
365378
})
366379
```
@@ -376,6 +389,7 @@ lf.setTheme({
376389
|selectedStroke|color|连线选中颜色|#000000|
377390
|outlineColor|color|外边框颜色|#000000|
378391
|offset|number|折线起终点距离节点的偏移|30|
392+
|outlineStrokeDashArray|string|控制用来描外边框的点划线的图案范式, 设置为空是为实线|'3,3'|
379393
<details>
380394
<summary>点击展开查看折线样式设置</summary>
381395

@@ -388,6 +402,8 @@ lf.setTheme({
388402
selectedStroke: '#000000',
389403
selectedShadow: true,
390404
offset: 30,
405+
outlineColor: '#000000',
406+
outlineStrokeDashArray: '3,3',
391407
},
392408
})
393409
```

packages/core/src/constant/DefaultTheme.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const commonStyle = {
88
strokeOpacity: 1,
99
opacity: 1,
1010
outlineColor: '#000000',
11+
outlineStrokeDashArray: '3,3',
1112
};
1213
const rect = {
1314
...commonStyle,
@@ -51,6 +52,7 @@ const edge = {
5152
hoverStroke: '#000000',
5253
selectedStroke: '#000000',
5354
outlineColor: '#000000',
55+
outlineStrokeDashArray: '3,3',
5456
};
5557
const line = {
5658
...edge,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class BaseEdgeModel implements IBaseModel {
5252
@observable strokeWidth = defaultData.strokeWidth;
5353
@observable stroke = defaultData.stroke;
5454
@observable outlineColor = defaultData.outlineColor;
55+
@observable outlineStrokeDashArray = defaultData.outlineStrokeDashArray;
5556
@observable strokeOpacity = defaultData.strokeOpacity;
5657
@observable zIndex = defaultData.zIndex;
5758
@observable isSelected = defaultData.isSelected;

packages/core/src/model/node/BaseNodeModel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export default class BaseNodeModel implements IBaseModel {
6363
@observable strokeOpacity = defaultConfig.strokeOpacity;
6464
@observable opacity = defaultConfig.opacity;
6565
@observable outlineColor = defaultConfig.outlineColor;
66+
@observable outlineStrokeDashArray = defaultConfig.outlineStrokeDashArray;
6667
@observable isSelected = false;
6768
@observable isHovered = false;
6869
@observable isHitable = true; // 细粒度控制节点是否对用户操作进行反应

packages/core/src/view/overlay/OutlineOverlay.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ type IProps = {
1212
graphModel: GraphModel;
1313
};
1414

15-
const STROKE_DASH_ARRAY = '3, 3';
16-
1715
@observer
1816
export default class OutlineOverlay extends Component<IProps> {
1917
// 节点outline
@@ -24,7 +22,7 @@ export default class OutlineOverlay extends Component<IProps> {
2422
for (let i = 0; i < nodeList.length; i++) {
2523
const node = nodeList[i];
2624
const {
27-
isSelected, x, y, width, height, outlineColor,
25+
isSelected, x, y, width, height, outlineColor, outlineStrokeDashArray,
2826
} = node;
2927
if (isSelected) {
3028
nodeOutline.push(
@@ -36,7 +34,7 @@ export default class OutlineOverlay extends Component<IProps> {
3634
radius={0}
3735
fill="none"
3836
stroke={outlineColor}
39-
strokeDasharray={STROKE_DASH_ARRAY}
37+
strokeDasharray={outlineStrokeDashArray}
4038
/>,
4139
);
4240
}
@@ -70,7 +68,7 @@ export default class OutlineOverlay extends Component<IProps> {
7068
const width = Math.abs(startPoint.x - endPoint.x) + 10;
7169
const height = Math.abs(startPoint.y - endPoint.y) + 10;
7270
const { graphModel } = this.props;
73-
const { outlineColor } = graphModel.theme.line;
71+
const { outlineColor, outlineStrokeDashArray } = graphModel.theme.line;
7472
return (
7573
<Rect
7674
className="lf-outline-edge"
@@ -80,7 +78,7 @@ export default class OutlineOverlay extends Component<IProps> {
8078
radius={0}
8179
fill="none"
8280
stroke={outlineColor}
83-
strokeDasharray={STROKE_DASH_ARRAY}
81+
strokeDasharray={outlineStrokeDashArray}
8482
/>
8583
);
8684
}
@@ -93,7 +91,7 @@ export default class OutlineOverlay extends Component<IProps> {
9391
x, y, width, height,
9492
} = bbox;
9593
const { graphModel } = this.props;
96-
const { outlineColor } = graphModel.theme.polyline;
94+
const { outlineColor, outlineStrokeDashArray } = graphModel.theme.polyline;
9795
return (
9896
<Rect
9997
className="lf-outline"
@@ -103,7 +101,7 @@ export default class OutlineOverlay extends Component<IProps> {
103101
radius={0}
104102
fill="none"
105103
stroke={outlineColor}
106-
strokeDasharray={STROKE_DASH_ARRAY}
104+
strokeDasharray={outlineStrokeDashArray}
107105
/>
108106
);
109107
}
@@ -116,7 +114,7 @@ export default class OutlineOverlay extends Component<IProps> {
116114
x, y, width, height,
117115
} = bbox;
118116
const { graphModel } = this.props;
119-
const { outlineColor } = graphModel.theme.bezier;
117+
const { outlineColor, outlineStrokeDashArray } = graphModel.theme.bezier;
120118
return (
121119
<Rect
122120
className="lf-outline"
@@ -126,7 +124,7 @@ export default class OutlineOverlay extends Component<IProps> {
126124
radius={0}
127125
fill="none"
128126
stroke={outlineColor}
129-
strokeDasharray={STROKE_DASH_ARRAY}
127+
strokeDasharray={outlineStrokeDashArray}
130128
/>
131129
);
132130
}

0 commit comments

Comments
 (0)