-
Notifications
You must be signed in to change notification settings - Fork 197
projection autoheight #1162
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
projection autoheight #1162
Conversation
e8825f7 to
e87ebe5
Compare
|
it works! Can uses the projection's ratio (e.g. 1 for orthographic, 0.5 for equirectangular); measures the path if a domain is given. Defaults to the golden ratio for any other projection. |
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.
This extends the public interface of what we’re calling a projection to include projection.ratio (rather than just the existing projection.stream). Do we intend to support user-supplied projections with auto-height by having them supply projection.ratio? Or do we only want to support this for the built-in projections? I think I probably wouldn’t use this mechanism as the public interface… especially since we could potentially infer the ratio by projecting the outline via projection.stream and d3.geoPath.bounds. But I also think it’s not a high priority to support this for custom projections. Given the time pressure I’d prefer to only do this for our internal projections to start.
|
I've tried to hide the .ratio property in #1163, with a Symbol. (In the future we might consider opening it, but adding domain: sphere should be fine in most (all?) cases. Just a weeny bit slower.) |
|
I need to think about this one more. |
|
I made the same mistake to have autoHeight depend on the actual user-given margins and width, when it should depend on the defaults (otherwise changing the width will also change the default height). If we want to make everything fit exactly with user specified dimensions (and domain), this starts to look much more like the dataAspectRatio option (discussed in #837). It could be done as a follow-up in a comprehensive manner, maybe as an opt-in In the meantime I'll put up a much simpler alternative. |
the height for projections (including the null projection when Plot.geo is used) is computed for a target frame with an aspect ratio that defaults to the golden ratio. When using facets, the computation takes into account the number of rows and columns, with similar limits to what total size is acceptable (1260px). The projection's preferred aspect ratio is adapted for a few named projections. For example "equal-earth" and "equirectangular" are wider than tall, "mercator" and a few azimuthal projections default to a square. closes #1136 supersedes #1162
* autoHeight the height for projections (including the null projection when Plot.geo is used) is computed for a target frame with an aspect ratio that defaults to the golden ratio. When using facets, the computation takes into account the number of rows and columns, with similar limits to what total size is acceptable (1260px). The projection's preferred aspect ratio is adapted for a few named projections. For example "equal-earth" and "equirectangular" are wider than tall, "mercator" and a few azimuthal projections default to a square. closes #1136 supersedes #1162 * determine the width of a facet from the (default) value of paddingInner=0.1, paddingOuter=0, instead of relying on the fx scale still being in the intermediate state where its range is [0,1]. There's a 2px discrepancy in the tests, which is probably coming from some rounding. * refactor: use the ratio implied by tx and ty * aspectRatio * auto height based on width * Update src/dimensions.js Co-authored-by: Philippe Rivière <fil@rezo.net> * fix auto height when geometry-less projection * fix default height for custom projections Co-authored-by: Mike Bostock <mbostock@gmail.com>
* autoHeight the height for projections (including the null projection when Plot.geo is used) is computed for a target frame with an aspect ratio that defaults to the golden ratio. When using facets, the computation takes into account the number of rows and columns, with similar limits to what total size is acceptable (1260px). The projection's preferred aspect ratio is adapted for a few named projections. For example "equal-earth" and "equirectangular" are wider than tall, "mercator" and a few azimuthal projections default to a square. closes observablehq#1136 supersedes observablehq#1162 * determine the width of a facet from the (default) value of paddingInner=0.1, paddingOuter=0, instead of relying on the fx scale still being in the intermediate state where its range is [0,1]. There's a 2px discrepancy in the tests, which is probably coming from some rounding. * refactor: use the ratio implied by tx and ty * aspectRatio * auto height based on width * Update src/dimensions.js Co-authored-by: Philippe Rivière <fil@rezo.net> * fix auto height when geometry-less projection * fix default height for custom projections Co-authored-by: Mike Bostock <mbostock@gmail.com>
closes #1136