-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Determine the default height when the projection domain is set #2102
Conversation
src/projection.js
Outdated
@@ -167,8 +167,10 @@ function scaleProjection(createProjection, kx, ky) { | |||
if (precision != null) projection.precision?.(precision); | |||
if (rotate != null) projection.rotate?.(rotate); | |||
if (typeof clip === "number") projection.clipAngle?.(clip); | |||
projection.scale(Math.min(width / kx, height / ky)); | |||
projection.translate([width / 2, height / 2]); | |||
if (width && height) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
71bdbe7
to
17328e4
Compare
(I don't think this feature is much documented, it "just works".)
closes #2063