Skip to content

Commit 85f2c49

Browse files
committed
default paintOrder
1 parent 8518555 commit 85f2c49

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

src/marks/text.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import {Mark} from "../plot.js";
66
import {applyChannelStyles, applyDirectStyles, applyIndirectStyles, applyAttr, applyTransform, offset, impliedString, applyFrameAnchor} from "../style.js";
77

88
const defaults = {
9-
strokeLinejoin: "round"
9+
strokeLinejoin: "round",
10+
strokeWidth: 3,
11+
paintOrder: "stroke"
1012
};
1113

1214
export class Text extends Mark {
@@ -39,10 +41,7 @@ export class Text extends Mark {
3941
{name: "rotate", value: numberChannel(vrotate), optional: true},
4042
{name: "text", value: text, filter: nonempty}
4143
],
42-
{
43-
...options.stroke && {paintOrder: "stroke", strokeWidth: 3},
44-
...options
45-
},
44+
options,
4645
defaults
4746
);
4847
this.rotate = crotate;

src/style.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export function styles(
3232
strokeWidth: defaultStrokeWidth,
3333
strokeLinecap: defaultStrokeLinecap,
3434
strokeLinejoin: defaultStrokeLinejoin,
35-
strokeMiterlimit: defaultStrokeMiterlimit
35+
strokeMiterlimit: defaultStrokeMiterlimit,
36+
paintOrder: defaultPaintOrder
3637
}
3738
) {
3839

@@ -73,6 +74,10 @@ export function styles(
7374
if (strokeLinecap === undefined) strokeLinecap = defaultStrokeLinecap;
7475
if (strokeLinejoin === undefined) strokeLinejoin = defaultStrokeLinejoin;
7576
if (strokeMiterlimit === undefined) strokeMiterlimit = defaultStrokeMiterlimit;
77+
78+
// The paint order only takes effect if there is both a fill and a stroke
79+
// (at least if we ignore markers, which no built-in marks currently use).
80+
if (cfill !== "none" && paintOrder === undefined) paintOrder = defaultPaintOrder;
7681
}
7782

7883
const [vstrokeWidth, cstrokeWidth] = maybeNumberChannel(strokeWidth);

test/output/metroInequalityChange.svg

Lines changed: 1 addition & 1 deletion
Loading

test/plots/metro-inequality-change.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export default async function() {
3434
text: "nyt_display",
3535
fill: "black",
3636
stroke: "white",
37-
strokeWidth: 4,
3837
dy: -8
3938
})
4039
]

0 commit comments

Comments
 (0)