Skip to content

Commit 8229321

Browse files
committed
fix offset bug; we want the same image independently of the slight translation we apply on lower DPI screens
1 parent bab4fbb commit 8229321

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/marks/hexgrid.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {create} from "../context.js";
22
import {Mark} from "../mark.js";
33
import {number, singleton} from "../options.js";
4-
import {applyChannelStyles, applyDirectStyles, applyIndirectStyles, applyTransform, offset} from "../style.js";
4+
import {applyChannelStyles, applyDirectStyles, applyIndirectStyles, applyTransform} from "../style.js";
55
import {sqrt4_3} from "../symbol.js";
66
import {ox, oy} from "../transforms/hexbin.js";
77

@@ -47,7 +47,7 @@ export class Hexgrid extends Mark {
4747
return create("svg:g", context)
4848
.datum(0)
4949
.call(applyIndirectStyles, this, dimensions, context)
50-
.call(applyTransform, this, {}, offset + ox, offset + oy)
50+
.call(applyTransform, this, {}, ox, oy)
5151
.call((g) => g.append("path").call(applyDirectStyles, this).call(applyChannelStyles, this, channels).attr("d", d))
5252
.node();
5353
}

src/transforms/hexbin.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {map, number, valueof} from "../options.js";
22
import {applyPosition} from "../projection.js";
3+
import {offset} from "../style.js";
34
import {sqrt3} from "../symbol.js";
45
import {initializer} from "./basic.js";
56
import {hasOutput, maybeGroup, maybeGroupOutputs, maybeSubgroup} from "./group.js";
@@ -9,8 +10,8 @@ import {hasOutput, maybeGroup, maybeGroupOutputs, maybeSubgroup} from "./group.j
910
// to be rounded up into a floating bin to the right of the plot. Therefore,
1011
// rather than centering the origin hexagon around ⟨0,0⟩ in screen coordinates,
1112
// we offset slightly to ⟨0.5,0⟩. The hexgrid mark uses the same origin.
12-
export const ox = 0.5,
13-
oy = 0;
13+
export const ox = 0.5 - offset;
14+
export const oy = -offset;
1415

1516
export function hexbin(outputs = {fill: "count"}, {binWidth, ...options} = {}) {
1617
const {z} = options;

0 commit comments

Comments
 (0)