Skip to content

Commit b66b618

Browse files
committed
link strokeOpacity
1 parent b426c13 commit b66b618

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/marks/link.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {ascending} from "d3";
22
import {create} from "d3";
33
import {filter} from "../defined.js";
4-
import {Mark, maybeColor, title} from "../mark.js";
4+
import {Mark, maybeColor, maybeNumber, title} from "../mark.js";
55
import {Style, applyDirectStyles, applyIndirectStyles, applyTransform, applyAttr} from "../style.js";
66

77
export class Link extends Mark {
@@ -15,10 +15,12 @@ export class Link extends Mark {
1515
z,
1616
title,
1717
stroke,
18+
strokeOpacity,
1819
...options
1920
} = {}
2021
) {
2122
const [vstroke, cstroke] = maybeColor(stroke, "currentColor");
23+
const [vstrokeOpacity, cstrokeOpacity] = maybeNumber(strokeOpacity);
2224
super(
2325
data,
2426
[
@@ -28,18 +30,23 @@ export class Link extends Mark {
2830
{name: "y2", value: y2, scale: "y"},
2931
{name: "z", value: z, optional: true},
3032
{name: "title", value: title, optional: true},
31-
{name: "stroke", value: vstroke, scale: "color", optional: true}
33+
{name: "stroke", value: vstroke, scale: "color", optional: true},
34+
{name: "strokeOpacity", value: vstrokeOpacity, scale: "opacity", optional: true}
3235
],
3336
options
3437
);
35-
Style(this, {stroke: cstroke, ...options});
38+
Style(this, {
39+
stroke: cstroke,
40+
strokeOpacity: cstrokeOpacity,
41+
...options
42+
});
3643
}
3744
render(
3845
I,
3946
{x, y},
40-
{x1: X1, y1: Y1, x2: X2, y2: Y2, z: Z, title: L, stroke: S}
47+
{x1: X1, y1: Y1, x2: X2, y2: Y2, z: Z, title: L, stroke: S, strokeOpacity: SO}
4148
) {
42-
const index = filter(I, X1, Y1, X2, Y2, S);
49+
const index = filter(I, X1, Y1, X2, Y2, S, SO);
4350
if (Z) index.sort((i, j) => ascending(Z[i], Z[j]));
4451
return create("svg:g")
4552
.call(applyIndirectStyles, this)
@@ -53,6 +60,7 @@ export class Link extends Mark {
5360
.attr("x2", i => X2[i])
5461
.attr("y2", i => Y2[i])
5562
.call(applyAttr, "stroke", S && (i => S[i]))
63+
.call(applyAttr, "stroke-opacity", SO && (i => SO[i]))
5664
.call(title(L)))
5765
.node();
5866
}

0 commit comments

Comments
 (0)