Skip to content

Commit 9cb3ec3

Browse files
committed
snap tip to round pixels
1 parent 2c92db0 commit 9cb3ec3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/marks/tip.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export class Tip extends Mark {
148148
.data(index)
149149
.enter()
150150
.append("g")
151-
.attr("transform", (i) => `translate(${px(i)},${py(i)})`)
151+
.attr("transform", (i) => `translate(${Math.round(px(i))},${Math.round(py(i))})`) // crisp edges
152152
.call(applyDirectStyles, this)
153153
.call((g) => g.append("path").attr("filter", pathFilter))
154154
.call((g) =>
@@ -205,7 +205,8 @@ export class Tip extends Mark {
205205
function postrender() {
206206
const {width, height} = dimensions.facet ?? dimensions;
207207
g.selectChildren().each(function (i) {
208-
const {x: tx, width: w, height: h} = this.getBBox();
208+
let {x: tx, width: w, height: h} = this.getBBox();
209+
(w = Math.round(w)), (h = Math.round(h)); // crisp edges
209210
let a = anchor; // use the specified anchor, if any
210211
if (a === undefined) {
211212
a = mark.previousAnchor; // favor the previous anchor, if it fits

0 commit comments

Comments
 (0)