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

set context.path early #2252

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

set context.path early #2252

wants to merge 6 commits into from

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Nov 24, 2024

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.

@Fil Fil requested a review from mbostock November 24, 2024 11:28
@Fil Fil marked this pull request as draft November 24, 2024 11:29
@Fil
Copy link
Contributor Author

Fil commented Nov 24, 2024

Marking as draft as I have to double-check that we're not applying scales twice.

@Fil Fil marked this pull request as ready for review November 24, 2024 11:41
Copy link
Member

@mbostock mbostock left a 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.

Comment on lines 160 to +165
context.projection = createProjection(options, subdimensions);

// A path generator for marks that want to draw GeoJSON.
context.path = function () {
return geoPath(this.projection ?? xyProjection(scales));
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants