Skip to content

Commit 7e45462

Browse files
martgnzFilmbostock
authored
Add shape-rendering to mark style (#419)
* Add shape-rendering * Add tests * Update test/plots/us-presidential-forecast-2016.js * Update test/plots/us-presidential-forecast-2016.js * Consistent quotes * shapeRendering defaults to auto * rule, not bar Co-authored-by: Philippe Rivière <[email protected]> Co-authored-by: Mike Bostock <[email protected]>
1 parent 6b9c3d6 commit 7e45462

16 files changed

+1178
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ All marks support the following style options:
462462
* **strokeMiterlimit** - to limit the length of *miter* joins
463463
* **strokeDasharray** - a comma-separated list of dash lengths (in pixels)
464464
* **mixBlendMode** - the [blend mode](https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode) (*e.g.*, *multiply*)
465+
* **shapeRendering** - the [shape-rendering mode](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering) (*e.g.*, *crispEdges*)
465466

466467
All marks support the following optional channels:
467468

src/style.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export function Style(mark, {
1212
strokeLinecap,
1313
strokeMiterlimit,
1414
strokeDasharray,
15-
mixBlendMode
15+
mixBlendMode,
16+
shapeRendering
1617
} = {}) {
1718
mark.fill = impliedString(fill, "currentColor");
1819
mark.fillOpacity = impliedNumber(fillOpacity, 1);
@@ -24,6 +25,7 @@ export function Style(mark, {
2425
mark.strokeMiterlimit = impliedNumber(strokeMiterlimit, 4);
2526
mark.strokeDasharray = string(strokeDasharray);
2627
mark.mixBlendMode = impliedString(mixBlendMode, "normal");
28+
mark.shapeRendering = impliedString(shapeRendering, "auto");
2729
}
2830

2931
export function applyIndirectStyles(selection, mark) {
@@ -36,6 +38,7 @@ export function applyIndirectStyles(selection, mark) {
3638
applyAttr(selection, "stroke-linecap", mark.strokeLinecap);
3739
applyAttr(selection, "stroke-miterlimit", mark.strokeMiterlimit);
3840
applyAttr(selection, "stroke-dasharray", mark.strokeDasharray);
41+
applyAttr(selection, "shape-rendering", mark.shapeRendering);
3942
}
4043

4144
export function applyDirectStyles(selection, mark) {

0 commit comments

Comments
 (0)