Skip to content

Commit 85da8d3

Browse files
committed
fix collapsing bug (#1742)
1 parent e44dd3d commit 85da8d3

File tree

5 files changed

+6325
-4
lines changed

5 files changed

+6325
-4
lines changed

src/plot.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {arrayify, map, yes, maybeIntervalTransform, subarray} from "./options.js
1414
import {createProjection, getGeometryChannels, hasProjection} from "./projection.js";
1515
import {createScales, createScaleFunctions, autoScaleRange, exposeScales} from "./scales.js";
1616
import {innerDimensions, outerDimensions} from "./scales.js";
17-
import {position, registry as scaleRegistry} from "./scales/index.js";
17+
import {position, projection, registry as scaleRegistry} from "./scales/index.js";
1818
import {applyInlineStyles, maybeClassName} from "./style.js";
1919
import {initializer} from "./transforms/basic.js";
2020
import {consumeWarnings, warn} from "./warnings.js";
@@ -201,7 +201,7 @@ export function plot(options = {}) {
201201
// channels as-is rather than creating new scales, and assume that
202202
// they already have the scale’s transform applied, if any (e.g., when
203203
// generating ticks for the axis mark).
204-
if (scale != null && scaleRegistry.get(scale) !== position) {
204+
if (scale != null && ![position, projection].includes(scaleRegistry.get(scale))) {
205205
applyScaleTransform(channel, options);
206206
newByScale.add(scale);
207207
}
@@ -502,7 +502,7 @@ function maybeMarkFacet(mark, topFacetState, options) {
502502
}
503503

504504
function derive(mark, options = {}) {
505-
return initializer({...options, x: null, y: null}, (data, facets, channels, scales, dimensions, context) => {
505+
return initializer({...options, x: null, y: null}, (_data, _facets, _channels, scales, dimensions, context) => {
506506
return context.getMarkState(mark);
507507
});
508508
}

src/transforms/centroid.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ export function centroid({geometry = identity, ...options} = {}) {
1111
const Y = new Float64Array(n);
1212
const path = geoPath(projection);
1313
for (let i = 0; i < n; ++i) [X[i], Y[i]] = path.centroid(G[i]);
14-
return {data, facets, channels: {x: {value: X, source: null}, y: {value: Y, source: null}}};
14+
return {
15+
data,
16+
facets,
17+
channels: {
18+
x: {value: X, scale: projection == null ? "x" : null, source: null},
19+
y: {value: Y, scale: projection == null ? "y" : null, source: null}
20+
}
21+
};
1522
});
1623
}
1724

0 commit comments

Comments
 (0)