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

expose projection #2038

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

expose projection #2038

wants to merge 1 commit into from

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Mar 26, 2024

This is more the direction in which I'd like to go: expose just enough to make it possible to reuse the projection in another chart (we're not there yet), and to support advanced brushing (uwdata/mosaic#336).

(Not solved yet!)

We need:

  • more concrete use cases (of reuse)
  • tests
  • enough information to recreate the same projection
  • invert: currently lost in translation (^^), but we could do it by being more careful when we compose with the scale+translate transform. (The clip transform is traditionally ignored/considered as a pass-thru when inverting.)

This somewhat supersedes @jheer's suggestion in #1191 (comment)

closes #1191

/** The projection’s name, if specified. */
name?: string;
/** A function that projects a point coordinates. */
point: (point: [number, number]) => [x: number, y: number] | undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Should this be apply to match a scale? (And we might want an invert, too?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but I was wondering if apply should be for geometries, not points. However we can handle both types since they're easy to detect (geometries have a .type property).

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.

Seems directionally good, but I don’t think it maintains the principle of the materialized projection having the same shape (or being usable) as the projection options, like we do for plot.scale(). Meaning, we want to be able to call plot.projection() and then pass the resulting object into Plot.plot as the projection option and get the same behavior. (Or maybe it does work because of the projection.stream property and I just missed it?)

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.

expose the projection to make it reusable
2 participants