-
Notifications
You must be signed in to change notification settings - Fork 184
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
set context.path early #2252
base: main
Are you sure you want to change the base?
set context.path early #2252
Conversation
✅ |
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.
I think this belongs as an assignment in the plot
function, rather than in createContext
, because we likewise assign context.projection
in the plot
function, too.
context.projection = createProjection(options, subdimensions); | ||
|
||
// A path generator for marks that want to draw GeoJSON. | ||
context.path = function () { | ||
return geoPath(this.projection ?? xyProjection(scales)); | ||
}; |
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.
context.projection = createProjection(options, subdimensions); | |
// A path generator for marks that want to draw GeoJSON. | |
context.path = function () { | |
return geoPath(this.projection ?? xyProjection(scales)); | |
}; | |
const projection = context.projection = createProjection(options, subdimensions); | |
// A path generator for marks that want to draw GeoJSON. | |
context.path = () => geoPath(projection ?? xyProjection(scales)); |
this is maybe more consistent?
Re: #2243 (comment)
My thinking initially was that we needed the scales to be ready, but in fact the position scales are ready when we create the context (initializers can set color, r, etc., but not x or y).
The centroid initializer now uses context.path. (The line mark render, and the link mark render, could already have used it before but I hadn't seen it; now they do, too.)
Note: currently legends create a context without passing the scales. They don't call context.path so it's not a problem, but if we wanted a legend to draw a geojson some time in the future, it would just have to pass scales.