Skip to content

Commit

Permalink
default paintOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Jan 25, 2022
1 parent 8518555 commit 85f2c49
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/marks/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {Mark} from "../plot.js";
import {applyChannelStyles, applyDirectStyles, applyIndirectStyles, applyAttr, applyTransform, offset, impliedString, applyFrameAnchor} from "../style.js";

const defaults = {
strokeLinejoin: "round"
strokeLinejoin: "round",
strokeWidth: 3,
paintOrder: "stroke"
};

export class Text extends Mark {
Expand Down Expand Up @@ -39,10 +41,7 @@ export class Text extends Mark {
{name: "rotate", value: numberChannel(vrotate), optional: true},
{name: "text", value: text, filter: nonempty}
],
{
...options.stroke && {paintOrder: "stroke", strokeWidth: 3},
...options
},
options,
defaults
);
this.rotate = crotate;
Expand Down
7 changes: 6 additions & 1 deletion src/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export function styles(
strokeWidth: defaultStrokeWidth,
strokeLinecap: defaultStrokeLinecap,
strokeLinejoin: defaultStrokeLinejoin,
strokeMiterlimit: defaultStrokeMiterlimit
strokeMiterlimit: defaultStrokeMiterlimit,
paintOrder: defaultPaintOrder
}
) {

Expand Down Expand Up @@ -73,6 +74,10 @@ export function styles(
if (strokeLinecap === undefined) strokeLinecap = defaultStrokeLinecap;
if (strokeLinejoin === undefined) strokeLinejoin = defaultStrokeLinejoin;
if (strokeMiterlimit === undefined) strokeMiterlimit = defaultStrokeMiterlimit;

// The paint order only takes effect if there is both a fill and a stroke
// (at least if we ignore markers, which no built-in marks currently use).
if (cfill !== "none" && paintOrder === undefined) paintOrder = defaultPaintOrder;
}

const [vstrokeWidth, cstrokeWidth] = maybeNumberChannel(strokeWidth);
Expand Down
2 changes: 1 addition & 1 deletion test/output/metroInequalityChange.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion test/plots/metro-inequality-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export default async function() {
text: "nyt_display",
fill: "black",
stroke: "white",
strokeWidth: 4,
dy: -8
})
]
Expand Down

0 comments on commit 85f2c49

Please sign in to comment.