Skip to content

Commit 166da52

Browse files
authored
strokeDashoffset (#750)
1 parent 776d3ed commit 166da52

File tree

13 files changed

+20
-2
lines changed

13 files changed

+20
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,8 @@ All marks support the following style options:
622622
* **strokeLinejoin** - how to join lines (*bevel*, *miter*, *miter-clip*, or *round*)
623623
* **strokeLinecap** - how to cap lines (*butt*, *round*, or *square*)
624624
* **strokeMiterlimit** - to limit the length of *miter* joins
625-
* **strokeDasharray** - a comma-separated list of dash lengths (in pixels)
625+
* **strokeDasharray** - a comma-separated list of dash lengths (typically in pixels)
626+
* **strokeDashoffset** - the [stroke dash offset](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dashoffset) (typically in pixels)
626627
* **opacity** - object opacity (a number between 0 and 1)
627628
* **mixBlendMode** - the [blend mode](https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode) (*e.g.*, *multiply*)
628629
* **shapeRendering** - the [shape-rendering mode](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering) (*e.g.*, *crispEdges*)

src/style.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export function styles(
2323
strokeLinecap,
2424
strokeMiterlimit,
2525
strokeDasharray,
26+
strokeDashoffset,
2627
opacity,
2728
mixBlendMode,
2829
paintOrder,
@@ -104,7 +105,8 @@ export function styles(
104105
mark.strokeLinejoin = impliedString(strokeLinejoin, "miter");
105106
mark.strokeLinecap = impliedString(strokeLinecap, "butt");
106107
mark.strokeMiterlimit = impliedNumber(strokeMiterlimit, 4);
107-
mark.strokeDasharray = string(strokeDasharray);
108+
mark.strokeDasharray = impliedString(strokeDasharray, "none");
109+
mark.strokeDashoffset = impliedString(strokeDashoffset, "0");
108110
}
109111

110112
mark.target = string(target);
@@ -185,6 +187,7 @@ export function applyIndirectStyles(selection, mark) {
185187
applyAttr(selection, "stroke-linecap", mark.strokeLinecap);
186188
applyAttr(selection, "stroke-miterlimit", mark.strokeMiterlimit);
187189
applyAttr(selection, "stroke-dasharray", mark.strokeDasharray);
190+
applyAttr(selection, "stroke-dashoffset", mark.strokeDashoffset);
188191
applyAttr(selection, "shape-rendering", mark.shapeRendering);
189192
applyAttr(selection, "paint-order", mark.paintOrder);
190193
}

test/marks/area-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ it("area(data, options) has the expected defaults", () => {
1919
assert.strictEqual(area.strokeLinecap, undefined);
2020
assert.strictEqual(area.strokeMiterlimit, undefined);
2121
assert.strictEqual(area.strokeDasharray, undefined);
22+
assert.strictEqual(area.strokeDashoffset, undefined);
2223
assert.strictEqual(area.mixBlendMode, undefined);
2324
assert.strictEqual(area.shapeRendering, undefined);
2425
});

test/marks/bar-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ it("barX() has the expected defaults", () => {
1717
assert.strictEqual(bar.strokeLinecap, undefined);
1818
assert.strictEqual(bar.strokeMiterlimit, undefined);
1919
assert.strictEqual(bar.strokeDasharray, undefined);
20+
assert.strictEqual(bar.strokeDashoffset, undefined);
2021
assert.strictEqual(bar.mixBlendMode, undefined);
2122
assert.strictEqual(bar.shapeRendering, undefined);
2223
assert.strictEqual(bar.insetTop, 0);
@@ -110,6 +111,7 @@ it("barY() has the expected defaults", () => {
110111
assert.strictEqual(bar.strokeLinecap, undefined);
111112
assert.strictEqual(bar.strokeMiterlimit, undefined);
112113
assert.strictEqual(bar.strokeDasharray, undefined);
114+
assert.strictEqual(bar.strokeDashoffset, undefined);
113115
assert.strictEqual(bar.mixBlendMode, undefined);
114116
assert.strictEqual(bar.shapeRendering, undefined);
115117
assert.strictEqual(bar.insetTop, 0);

test/marks/cell-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ it("cell() has the expected defaults", () => {
1919
assert.strictEqual(cell.strokeLinecap, undefined);
2020
assert.strictEqual(cell.strokeMiterlimit, undefined);
2121
assert.strictEqual(cell.strokeDasharray, undefined);
22+
assert.strictEqual(cell.strokeDashoffset, undefined);
2223
assert.strictEqual(cell.mixBlendMode, undefined);
2324
assert.strictEqual(cell.shapeRendering, undefined);
2425
assert.strictEqual(cell.insetTop, 0);

test/marks/dot-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ it("dot() has the expected defaults", () => {
1818
assert.strictEqual(dot.strokeLinecap, undefined);
1919
assert.strictEqual(dot.strokeMiterlimit, undefined);
2020
assert.strictEqual(dot.strokeDasharray, undefined);
21+
assert.strictEqual(dot.strokeDashoffset, undefined);
2122
assert.strictEqual(dot.mixBlendMode, undefined);
2223
assert.strictEqual(dot.shapeRendering, undefined);
2324
});

test/marks/frame-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ it("frame(options) has the expected defaults", () => {
1515
assert.strictEqual(frame.strokeLinecap, undefined);
1616
assert.strictEqual(frame.strokeMiterlimit, undefined);
1717
assert.strictEqual(frame.strokeDasharray, undefined);
18+
assert.strictEqual(frame.strokeDashoffset, undefined);
1819
assert.strictEqual(frame.mixBlendMode, undefined);
1920
assert.strictEqual(frame.shapeRendering, undefined);
2021
assert.strictEqual(frame.insetTop, 0);

test/marks/line-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ it("line() has the expected defaults", () => {
1919
assert.strictEqual(line.strokeLinecap, undefined);
2020
assert.strictEqual(line.strokeMiterlimit, 1);
2121
assert.strictEqual(line.strokeDasharray, undefined);
22+
assert.strictEqual(line.strokeDashoffset, undefined);
2223
assert.strictEqual(line.mixBlendMode, undefined);
2324
assert.strictEqual(line.shapeRendering, undefined);
2425
});

test/marks/link-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ it("link(data, options) has the expected defaults", () => {
1717
assert.strictEqual(link.strokeLinecap, undefined);
1818
assert.strictEqual(link.strokeMiterlimit, 1);
1919
assert.strictEqual(link.strokeDasharray, undefined);
20+
assert.strictEqual(link.strokeDashoffset, undefined);
2021
assert.strictEqual(link.mixBlendMode, undefined);
2122
assert.strictEqual(link.shapeRendering, undefined);
2223
});

test/marks/rect-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ it("rect(data, options) has the expected defaults", () => {
1717
assert.strictEqual(rect.strokeLinecap, undefined);
1818
assert.strictEqual(rect.strokeMiterlimit, undefined);
1919
assert.strictEqual(rect.strokeDasharray, undefined);
20+
assert.strictEqual(rect.strokeDashoffset, undefined);
2021
assert.strictEqual(rect.mixBlendMode, undefined);
2122
assert.strictEqual(rect.shapeRendering, undefined);
2223
assert.strictEqual(rect.insetTop, 0);

0 commit comments

Comments
 (0)