diff --git a/src/symbols.js b/src/symbols.js index bde756257d..48e8d39abb 100644 --- a/src/symbols.js +++ b/src/symbols.js @@ -5,7 +5,7 @@ const t = Math.sqrt(3) / 2; // TODO decide on radius definition const symbolHexagon = { draw(context, size) { - const s = Math.sqrt(size / Math.PI), hs = s / 2, ts = s * t; + const s = Math.sqrt(size / Math.PI) * 2 / Math.sqrt(3), hs = s / 2, ts = s * t; context.moveTo(0, s); context.lineTo(ts, hs); context.lineTo(ts, -hs); diff --git a/test/output/hexbin.svg b/test/output/hexbin.svg index a36bafe5d9..cd23ce724f 100644 --- a/test/output/hexbin.svg +++ b/test/output/hexbin.svg @@ -102,113 +102,168 @@ culmen_depth_mm → - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plots/hexbin.js b/test/plots/hexbin.js index fcf256137d..08d95b7179 100644 --- a/test/plots/hexbin.js +++ b/test/plots/hexbin.js @@ -12,13 +12,14 @@ export default async function() { y: "culmen_length_mm", symbol: "hexagon", initialize([index], {x: {value: X}, y: {value: Y}}, {x, y}) { - const bins = Hexbin().x(i => x(X[i])).y(i => y(Y[i])).radius(20)(index); + const radius = 12; + const bins = Hexbin().x(i => x(X[i])).y(i => y(Y[i])).radius(radius * 2 / Math.sqrt(3))(index); return { facets: [d3.range(bins.length)], channels: { x: {value: bins.map(bin => bin.x)}, y: {value: bins.map(bin => bin.y)}, - r: {value: bins.map(bin => bin.length), radius: 20, scale: "r"} + r: {value: bins.map(bin => bin.length), radius, scale: "r"} } }; }