Skip to content

Commit

Permalink
Only scale if passed a width (height being always passed with width, …
Browse files Browse the repository at this point in the history
…there's no need to check both)

the case where width and height are undefined is when we are testing the projection's aspect ratio with a given domain

Note that the path in the SVG is broken (full of NaN) when projection.scale() === 0. This seems to be a secondary issue.
  • Loading branch information
Fil committed Jul 11, 2024
1 parent 6d51cb5 commit 17328e4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/projection.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function scaleProjection(createProjection, kx, ky) {
if (precision != null) projection.precision?.(precision);
if (rotate != null) projection.rotate?.(rotate);
if (typeof clip === "number") projection.clipAngle?.(clip);
if (width && height) {
if (width != null) {
projection.scale(Math.min(width / kx, height / ky));
projection.translate([width / 2, height / 2]);
}
Expand All @@ -185,7 +185,7 @@ function conicProjection(createProjection, kx, ky) {
const projection = type(options);
if (parallels != null) {
projection.parallels(parallels);
if (domain === undefined && width && height) {
if (domain === undefined && width != null) {
projection.fitSize([width, height], {type: "Sphere"});
}
}
Expand Down
Loading

0 comments on commit 17328e4

Please sign in to comment.