Skip to content

Commit

Permalink
fix collapsing bug (#1742)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fil committed Jul 10, 2023
1 parent e44dd3d commit b3e1318
Show file tree
Hide file tree
Showing 5 changed files with 6,324 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {arrayify, map, yes, maybeIntervalTransform, subarray} from "./options.js
import {createProjection, getGeometryChannels, hasProjection} from "./projection.js";
import {createScales, createScaleFunctions, autoScaleRange, exposeScales} from "./scales.js";
import {innerDimensions, outerDimensions} from "./scales.js";
import {position, registry as scaleRegistry} from "./scales/index.js";
import {position, projection, registry as scaleRegistry} from "./scales/index.js";
import {applyInlineStyles, maybeClassName} from "./style.js";
import {initializer} from "./transforms/basic.js";
import {consumeWarnings, warn} from "./warnings.js";
Expand Down Expand Up @@ -201,7 +201,7 @@ export function plot(options = {}) {
// channels as-is rather than creating new scales, and assume that
// they already have the scale’s transform applied, if any (e.g., when
// generating ticks for the axis mark).
if (scale != null && scaleRegistry.get(scale) !== position) {
if (scale != null && ![position, projection].includes(scaleRegistry.get(scale))) {
applyScaleTransform(channel, options);
newByScale.add(scale);
}
Expand Down
9 changes: 8 additions & 1 deletion src/transforms/centroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ export function centroid({geometry = identity, ...options} = {}) {
const Y = new Float64Array(n);
const path = geoPath(projection);
for (let i = 0; i < n; ++i) [X[i], Y[i]] = path.centroid(G[i]);
return {data, facets, channels: {x: {value: X, source: null}, y: {value: Y, source: null}}};
return {
data,
facets,
channels: {
x: {value: X, scale: projection == null ? "x" : null, source: null},
y: {value: Y, scale: projection == null ? "y" : null, source: null}
}
};
});
}

Expand Down
Loading

0 comments on commit b3e1318

Please sign in to comment.