Skip to content

Commit cb2642d

Browse files
authored
default round text strokeJoin (#566)
1 parent 37a9502 commit cb2642d

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/marks/text.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import {filter, nonempty} from "../defined.js";
33
import {Mark, indexOf, identity, string, maybeNumber, maybeTuple, numberChannel} from "../mark.js";
44
import {applyChannelStyles, applyDirectStyles, applyIndirectStyles, applyAttr, applyTransform, offset} from "../style.js";
55

6-
const defaults = {};
6+
const defaults = {
7+
strokeLinejoin: "round"
8+
};
79

810
export class Text extends Mark {
911
constructor(data, options = {}) {

src/style.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export function styles(
2424
fill: defaultFill = "currentColor",
2525
stroke: defaultStroke = "none",
2626
strokeWidth: defaultStrokeWidth,
27+
strokeLinejoin: defaultStrokeLinejoin,
2728
strokeMiterlimit: defaultStrokeMiterlimit
2829
}
2930
) {
@@ -55,6 +56,7 @@ export function styles(
5556
// defaults if the stroke is not (constant) none.
5657
if (cstroke !== "none") {
5758
if (strokeWidth === undefined) strokeWidth = defaultStrokeWidth;
59+
if (strokeLinejoin === undefined) strokeLinejoin = defaultStrokeLinejoin;
5860
if (strokeMiterlimit === undefined) strokeMiterlimit = defaultStrokeMiterlimit;
5961
}
6062

test/marks/text-test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,10 @@ it("text(data, {fill}) allows fill to be a variable color", () => {
4949
assert.strictEqual(fill.value, "x");
5050
assert.strictEqual(fill.scale, "color");
5151
});
52+
53+
it("text(data, {stroke}) has a default strokeLinejoin of round", () => {
54+
const text = Plot.text(undefined, {stroke: "red"});
55+
assert.strictEqual(text.fill, "none");
56+
assert.strictEqual(text.stroke, "red");
57+
assert.strictEqual(text.strokeLinejoin, "round");
58+
});

0 commit comments

Comments
 (0)