Skip to content
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 #2063

Open
mbostock opened this issue May 1, 2024 · 0 comments
Open

Determine the default height when the projection domain is set #2063

mbostock opened this issue May 1, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@mbostock
Copy link
Member

mbostock commented May 1, 2024

We currently determine the default height for whole-world projections automatically (for named projections):

plot/src/projection.js

Lines 237 to 253 in 4bbad40

// When a named projection is specified, we can use its natural aspect ratio to
// determine a good value for the projection’s height based on the desired
// width. When we don’t have a way to know, the golden ratio is our best guess.
// Due to a circular dependency (we need to know the height before we can
// construct the projection), we have to test the raw projection option rather
// than the materialized projection; therefore we must be extremely careful that
// the logic of this function exactly matches createProjection above!
export function projectionAspectRatio(projection) {
if (typeof projection?.stream === "function") return defaultAspectRatio;
if (isObject(projection)) projection = projection.type;
if (projection == null) return;
if (typeof projection !== "function") {
const {aspectRatio} = namedProjection(projection);
if (aspectRatio) return aspectRatio;
}
return defaultAspectRatio;
}

It’d be nice to do that if the domain is specified, too. For example:

Plot.plot({
  projection: {
    type: "conic-conformal",
    parallels: [34.3333, 36.1667],
    rotate: [79, 0],
    domain: ncstate
  },
  marks: [
    Plot.geo(ncstate),
    Plot.geo(nccounties, {strokeOpacity: 0.1})
  ]
})
@mbostock mbostock added the enhancement New feature or request label May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant