Skip to content

Plot.select…({valid: ["x", "y", "r"]}) #991

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

Closed
wants to merge 1 commit into from
Closed

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Jul 14, 2022

will select from the values that are not filtered

this needs documentation and tests, and "valid" is not the right verb.

Example: https://observablehq.com/@observablehq/select-a-valid-point-991

alternative to #989

@Fil Fil requested review from mbostock and tophtucker July 14, 2022 06:20
@Fil Fil mentioned this pull request Jul 14, 2022
@tophtucker
Copy link
Contributor

this is a lil over my head now 😅

what would i pass as valid in my window example?

@Fil
Copy link
Contributor Author

Fil commented Jul 14, 2022

with this API it would be selectMaxX({valid: "y"}). Though you could do selectLast({valid: ["x", "y"]}) if what you want is the last point in the series that has a valid x and y.

      Plot.selectMaxX(
        Plot.windowY({
          valid: "y",
          k: 24,
          ...

@mbostock
Copy link
Member

I think it is probably too much to expect people to reason about which channels need to have defined values (or “valid”) for a data point to be considered. It would be much better to respect the mark filter which considers all of a mark’s channels and ensure consistency with rendering. However, we don’t know what the downstream mark is when applying the select transform, and hence the select transform can’t tell what options represent channels (or even access those channel values without computing them redundantly). This might be fixable by making the select transform an initializer, but I suspect that would introduce other problems and make it harder to understand. So, I think it’s probably better to stick with the proposal of #989 and hope that autocomplete guides people towards the appropriate select transform. Alternatively maybe the select transform could uniformly require the x and y channel values to be defined to consider selection (if those options are present)… but I’m not wild about redundantly computing those channels, especially implicitly.

@Fil
Copy link
Contributor Author

Fil commented Jul 15, 2022

redundantly computing those channels
this might get better if valueof would (optionally?) do memoization?

Agree with the comment, this was a dead end.

@Fil Fil closed this Jul 15, 2022
@Fil Fil deleted the fil/select-valid branch July 15, 2022 11:11
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.

3 participants