Skip to content

Commit bda1cc6

Browse files
committed
Plot.image applies the common dx, dy options.
1 parent 8831f60 commit bda1cc6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/marks/image.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,16 @@ export class Image extends Mark {
6868
if (H) index = index.filter(i => positive(H[i]));
6969
const cx = (marginLeft + width - marginRight) / 2;
7070
const cy = (marginTop + height - marginBottom) / 2;
71+
const {dx, dy} = this;
7172
return create("svg:g")
7273
.call(applyIndirectStyles, this)
7374
.call(applyTransform, x, y, offset, offset)
7475
.call(g => g.selectAll()
7576
.data(index)
7677
.join("image")
7778
.call(applyDirectStyles, this)
78-
.attr("x", W && X ? i => X[i] - W[i] / 2 : W ? i => cx - W[i] / 2 : X ? i => X[i] - this.width / 2 : cx - this.width / 2)
79-
.attr("y", H && Y ? i => Y[i] - H[i] / 2 : H ? i => cy - H[i] / 2 : Y ? i => Y[i] - this.height / 2 : cy - this.height / 2)
79+
.attr("x", W && X ? i => X[i] - W[i] / 2 + dx : W ? i => cx - W[i] / 2 + dx : X ? i => X[i] - this.width / 2 + dx : cx - this.width / 2 + dx)
80+
.attr("y", H && Y ? i => Y[i] - H[i] / 2 + dy : H ? i => cy - H[i] / 2 + dy : Y ? i => Y[i] - this.height / 2 + dy : cy - this.height / 2 + dy)
8081
.attr("width", W ? i => W[i] : this.width)
8182
.attr("height", H ? i => H[i] : this.height)
8283
.call(applyAttr, "href", S ? i => S[i] : this.src)

0 commit comments

Comments
 (0)