diff --git a/src/marks/hexgrid.js b/src/marks/hexgrid.js index ecc4355a7a..b3d131e375 100644 --- a/src/marks/hexgrid.js +++ b/src/marks/hexgrid.js @@ -1,7 +1,7 @@ import {create} from "../context.js"; import {Mark} from "../mark.js"; import {number, singleton} from "../options.js"; -import {applyChannelStyles, applyDirectStyles, applyIndirectStyles, applyTransform, offset} from "../style.js"; +import {applyChannelStyles, applyDirectStyles, applyIndirectStyles, applyTransform} from "../style.js"; import {sqrt4_3} from "../symbol.js"; import {ox, oy} from "../transforms/hexbin.js"; @@ -47,7 +47,7 @@ export class Hexgrid extends Mark { return create("svg:g", context) .datum(0) .call(applyIndirectStyles, this, dimensions, context) - .call(applyTransform, this, {}, offset + ox, offset + oy) + .call(applyTransform, this, {}, ox, oy) .call((g) => g.append("path").call(applyDirectStyles, this).call(applyChannelStyles, this, channels).attr("d", d)) .node(); } diff --git a/src/style.js b/src/style.js index 4fc1c9828a..36c511eb47 100644 --- a/src/style.js +++ b/src/style.js @@ -6,7 +6,7 @@ import {isNone, isNoneish, isRound, maybeColorChannel, maybeNumberChannel} from import {keyof, number, string} from "./options.js"; import {warn} from "./warnings.js"; -export const offset = (typeof window !== "undefined" ? window.devicePixelRatio > 1 : typeof it === "undefined") ? 0 : 0.5; // prettier-ignore +export const offset = typeof window !== "undefined" && !(window.devicePixelRatio > 1) ? 0.5 : 0; let nextClipId = 0; let nextPatternId = 0; diff --git a/src/transforms/hexbin.js b/src/transforms/hexbin.js index 54e409d0aa..51078eb708 100644 --- a/src/transforms/hexbin.js +++ b/src/transforms/hexbin.js @@ -1,5 +1,6 @@ import {map, number, valueof} from "../options.js"; import {applyPosition} from "../projection.js"; +import {offset} from "../style.js"; import {sqrt3} from "../symbol.js"; import {initializer} from "./basic.js"; import {hasOutput, maybeGroup, maybeGroupOutputs, maybeSubgroup} from "./group.js"; @@ -9,8 +10,8 @@ import {hasOutput, maybeGroup, maybeGroupOutputs, maybeSubgroup} from "./group.j // to be rounded up into a floating bin to the right of the plot. Therefore, // rather than centering the origin hexagon around ⟨0,0⟩ in screen coordinates, // we offset slightly to ⟨0.5,0⟩. The hexgrid mark uses the same origin. -export const ox = 0.5, - oy = 0; +export const ox = 0.5 - offset; +export const oy = -offset; export function hexbin(outputs = {fill: "count"}, {binWidth, ...options} = {}) { const {z} = options; diff --git a/test/output/aaplBollinger.svg b/test/output/aaplBollinger.svg index 1b83587f35..5094367828 100644 --- a/test/output/aaplBollinger.svg +++ b/test/output/aaplBollinger.svg @@ -13,78 +13,78 @@ white-space: pre; } -