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

“mid” interval transform #641

Merged
merged 2 commits into from
Jan 1, 2022
Merged

Conversation

mbostock
Copy link
Member

I prefer to keep the two transforms distinct: we’ll compute the midpoint of the interval for dot, text, and image, and the extent of the interval for other marks. This also allows the “mid” interval transform to avoid memoization.

In addition to your fix to pass data to the interval’s transform function in case x2 in computed before x1, I’ve also fixed the memoization to be bypassed if the data changes. This isn’t currently possible in Plot, but I could imagine us wanting to support data changing in the future, so fixing while I’m here.

@mbostock mbostock requested a review from Fil December 31, 2021 17:55
src/transforms/interval.js Outdated Show resolved Hide resolved
@Fil Fil merged commit ed26108 into fil/interval-transform Jan 1, 2022
@Fil Fil deleted the mbostock/mid-interval branch January 1, 2022 15:36
}
if (typeof interval.floor !== "function" || typeof interval.offset !== "function") throw new Error("invalid interval");
if (typeof interval.mid !== "function") {
Copy link
Member Author

Choose a reason for hiding this comment

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

This means we’ll have to wrap every interval with this object, even though we won’t end up using it in most places. I think it’d be better to only create the mid function if it’s needed.

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