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

interval scale override #1855

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

interval scale override #1855

wants to merge 4 commits into from

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Sep 12, 2023

The approach in this PR is to elevate the output of maybeIntervalK to a generalized ChannelSpec object {value, scale}.

However this breaks a few tests, because stackY passes x directly to valueof, which expects a Channel, not a generalized ChannelSpec.

To fix this locally I did cb29daa, but then I realized that (maybe) such ChannelSpec could be everywhere we call valueof… In that case, wouldn't the correct fix be to do this in valueof instead, not just only in the stack function:

--- a/src/options.js
+++ b/src/options.js
@@ -21,6 +21,8 @@ export function valueof(data, value, type) {
     ? map(data, constant(value), type)
     : typeof value?.transform === "function"
     ? maybeTypedArrayify(value.transform(data), type)
+    : value?.value !== undefined
+    ? valueof(data, maybeValue(value).value, type)
     : maybeTake(maybeTypedArrayify(value, type), data?.[reindex]);
 }

But this is such an encompassing change, that I'm a bit nervous, and confused to know if it's correct.

Re: bd80e5f it is possible to be more meticulous and only elevate to a {value, scale} object if the scale is not undefined. But I wanted to keep it simple to discuss the principle first.

Also, if I am meticulous here I hide the tests cases that break, which is not a good idea; so we'll probably need another test case on top of this! Speaking of which, the additional test case is a bit ad hoc — since we only have "x" or null the choice is quite limited. But it would be nice if we had a motivated use case.

closes #1329

@Fil Fil requested a review from mbostock September 12, 2023 14:12
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.

maybeIntervalK and other helpers drop per-channel scale overrides
1 participant