Skip to content

Conversation

@Fil
Copy link
Contributor

@Fil Fil commented Jul 11, 2024

(I don't think this feature is much documented, it "just works".)

closes #2063

@Fil Fil requested a review from mbostock July 11, 2024 11:54
if (typeof clip === "number") projection.clipAngle?.(clip);
projection.scale(Math.min(width / kx, height / ky));
projection.translate([width / 2, height / 2]);
if (width && height) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this check for nullish instead of zero?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! I was thinking aspectRatio, but this part returns the actual projection, so it should respect a collapsed (degenerate) projection.

I fixed it and added a test case (without the fix, the test case displays a map in the default scale, instead of a 0-height map…).

Note that the degenerate case is still slightly problematic, as its path’s d property is an invalid string "M NaN,NaN…" instead of being null. (A projection with a strictly negative scale returns null, so the "issue" is only for scale 0.)

…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.
@Fil Fil force-pushed the fil/projection-domain-ratio branch from 71bdbe7 to 17328e4 Compare July 11, 2024 14:43
@mbostock mbostock merged commit 2f7a2c7 into main Jul 28, 2024
@mbostock mbostock deleted the fil/projection-domain-ratio branch July 28, 2024 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Determine the default height when the projection domain is set

3 participants