Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make it easier to create a text halo #703

Merged
merged 3 commits into from
Jan 25, 2022
Merged

make it easier to create a text halo #703

merged 3 commits into from
Jan 25, 2022

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Jan 25, 2022

by defaulting paintOrder to stroke and strokeWidth to 3 if the stroke option is specified.

supersedes #667
closes #666

Note: I balanced between 3 and 4 for the default, and took the conservative approach. It creates a 1.5px "halo" which is just enough, maybe sometimes a bit too small, but at least never looks gross. Not setting strokeWidth results (as you mentioned) in a 0.5px stroke, which is not a very good default.

@Fil Fil requested a review from mbostock January 25, 2022 08:39
@Fil Fil mentioned this pull request Jan 25, 2022
2 tasks
Base automatically changed from mbostock/paintOrder to main January 25, 2022 15:47
…ke and strokeWidth to 3 if the stroke option is specified.

supersedes #667
closes #666
@@ -39,7 +39,10 @@ export class Text extends Mark {
{name: "rotate", value: numberChannel(vrotate), optional: true},
{name: "text", value: text, filter: nonempty}
],
options,
{
...options.stroke && {paintOrder: "stroke", strokeWidth: 3},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The strokeWidth only has an effect if there is a stroke, so we can simply move this to up the defaults declaration. Likewise, we could move the paintOrder up to defaults too and add some logic to style.js so only apply the default paintOrder if there’s both a fill and a stroke.

Alternatively, I was thinking that the strokeWidth would be 3 only if both a fill and stroke are specified, and that it would be 1.5 (or 1?) if only the stroke were specified.

@mbostock mbostock merged commit 5ba59d9 into main Jan 25, 2022
@mbostock mbostock deleted the fil/paintOrder branch January 25, 2022 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plot.text halo option(s)
2 participants