follow-up: derive x & y scale domains from geometry#1663
Conversation
| const [x, y] = getGeometryChannels(channel); | ||
| addScaleChannel(channelsByScale, "x", x); | ||
| addScaleChannel(channelsByScale, "y", y); | ||
| if (projection == null && x?.domain === undefined && y?.domain === undefined) { |
There was a problem hiding this comment.
I think we’ll need a fancier test than projection == null, per this comment on projectionAspectRatio:
Lines 225 to 241 in df3a3ad
A quick take, but should have more thought:
function hasProjection({projection} = {}) {
if (projection == null) return false;
if (typeof projection.stream === "function") return true;
if (isObject(projection)) projection = projection.type;
return projection != null;
}But the bad part is that the projection can be specified as a function (a “projection initializer”) which can return null indicating that there isn’t actually a projection. But maybe we don’t care about that nuance here, since this is really just a performance optimization and shouldn’t change the behavior?
There was a problem hiding this comment.
I don't think we even need to cover the projection: null and projection: {type: null} cases, tbh. Having a smart domain when projection===undefined would be enough to solve the casual use of Plot.geo with some geojson. If the user starts to specify a projection, then they know what they're doing.
There was a problem hiding this comment.
Hmm it was the other way round: we can only skip that geometry look-up if the projection is guaranteed to be non-nullish. Which is what you were saying :)
0dea987 to
a6d4533
Compare
* derive x & y scale domains from geometry * follow-up: derive x & y scale domains from geometry (#1663) * fix pending issues and add tests * optimize and comment * move hasProjection --------- Co-authored-by: Mike Bostock <mbostock@gmail.com> --------- Co-authored-by: Philippe Rivière <fil@rezo.net>
* derive x & y scale domains from geometry * follow-up: derive x & y scale domains from geometry (#1663) * fix pending issues and add tests * optimize and comment * move hasProjection --------- Co-authored-by: Mike Bostock <mbostock@gmail.com> --------- Co-authored-by: Philippe Rivière <fil@rezo.net>
* derive x & y scale domains from geometry * follow-up: derive x & y scale domains from geometry (observablehq#1663) * fix pending issues and add tests * optimize and comment * move hasProjection --------- Co-authored-by: Mike Bostock <mbostock@gmail.com> --------- Co-authored-by: Philippe Rivière <fil@rezo.net>
addresses TODO items in #1468 and adds/tweaks tests