Skip to content

Commit 1d2bd61

Browse files
change dashSize to dashArray
1 parent 4cd307d commit 1d2bd61

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

src/symbols/Edge.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export const Edge: FC<EdgeProps> = ({
156156
size = 1,
157157
fill,
158158
dashed = false,
159-
dashSize = 3
159+
dashArray = [3, 1]
160160
} = edge;
161161

162162
// Use subLabelPlacement from edge data if available, otherwise use the prop value
@@ -466,7 +466,7 @@ export const Edge: FC<EdgeProps> = ({
466466
curve={curve}
467467
curved={curved}
468468
dashed={dashed}
469-
dashSize={dashSize}
469+
dashArray={dashArray}
470470
id={id}
471471
opacity={selectionOpacity}
472472
size={size}

src/symbols/Line.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ export interface LineProps {
3939
dashed?: boolean;
4040

4141
/**
42-
* The size of the dash.
42+
* Dash pattern for the line: [dashSize, gapSize]
4343
*/
44-
dashSize?: number;
44+
dashArray?: [number, number];
4545

4646
/**
4747
* The unique identifier of the line.
@@ -120,7 +120,7 @@ export const Line: FC<LineProps> = ({
120120
curve,
121121
curved = false,
122122
dashed = false,
123-
dashSize = 3,
123+
dashArray = [3, 1],
124124
id,
125125
opacity = 1,
126126
size = 1,
@@ -138,21 +138,22 @@ export const Line: FC<LineProps> = ({
138138
// Create dashed material
139139
const dashedMaterial = useMemo(() => {
140140
if (!dashed) return null;
141+
const [dashSize, dashGap] = dashArray;
141142

142143
return new ShaderMaterial({
143144
uniforms: {
144145
color: { value: normalizedColor },
145146
opacity: { value: opacity },
146147
dashSize: { value: dashSize },
147-
gapSize: { value: 1 },
148+
gapSize: { value: dashGap },
148149
lineLength: { value: curve.getLength() }
149150
},
150151
vertexShader: dashedVertexShader,
151152
fragmentShader: dashedFragmentShader,
152153
transparent: true,
153154
depthTest: false
154155
});
155-
}, [dashed, normalizedColor, opacity, curve, dashSize]);
156+
}, [dashed, normalizedColor, opacity, curve, dashArray]);
156157

157158
// Do opacity seperate from vertices for perf
158159
const { lineOpacity } = useSpring({

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ export interface GraphEdge extends GraphElementBaseAttributes {
9595
dashed?: boolean;
9696

9797
/**
98-
* The size of the dash.
98+
* Dash pattern for the line: [dashSize, gapSize]
9999
*/
100-
dashSize?: number;
100+
dashArray?: [number, number];
101101

102102
/**
103103
* Placement of the subLabel relative to the main label.

stories/demos/Edges.story.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export const DashSize = () => (
167167
id: '1-2',
168168
label: '1-2',
169169
dashed: true,
170-
dashSize: 1
170+
dashArray: [1, 1]
171171
},
172172
{
173173
source: '2',
@@ -176,7 +176,7 @@ export const DashSize = () => (
176176
label: '2-3',
177177
size: 5,
178178
dashed: true,
179-
dashSize: 2
179+
dashArray: [3, 1]
180180
},
181181
{
182182
source: '3',
@@ -185,7 +185,7 @@ export const DashSize = () => (
185185
label: '3-4',
186186
size: 3,
187187
dashed: true,
188-
dashSize: 10
188+
dashArray: [5, 5]
189189
},
190190
{
191191
source: '4',
@@ -194,7 +194,7 @@ export const DashSize = () => (
194194
label: '4-5',
195195
size: 10,
196196
dashed: true,
197-
dashSize: 1
197+
dashArray: [7, 3]
198198
}
199199
]}
200200
/>

0 commit comments

Comments
 (0)