Skip to content

reindex #1662

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

Merged
merged 5 commits into from
Aug 18, 2023
Merged

reindex #1662

merged 5 commits into from
Aug 18, 2023

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Jun 1, 2023

This seems to be working? (ref. #1649)

demo contrasting the three branches:
https://observablehq.com/@observablehq/plot-reindex-1662

@Fil Fil requested a review from mbostock June 1, 2023 07:49
@Fil Fil mentioned this pull request Jun 1, 2023
@mbostock mbostock force-pushed the mbostock/exclusive-facets branch from 15e303a to fc59cae Compare August 18, 2023 20:18
@mbostock mbostock force-pushed the fil/exclusive-facets-reindex branch from 3292529 to daeb7d4 Compare August 18, 2023 20:18
src/options.js Outdated
@@ -17,6 +17,8 @@ export function valueof(data, value, type) {
? map(data, constant(value), type)
: typeof value?.transform === "function"
? maybeTypedArrayify(value.transform(data), type)
: value && data?.reindex
? maybeTypedMap(data.reindex, (i) => value[i], type)
Copy link
Member

Choose a reason for hiding this comment

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

This assumes that value is an array, but it’s technically possible to be an arbitrary iterator. (Though, I discovered there’s some confusion in isOptions.)

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.

Nice! 👏

I switched to using a symbol since that seems cleaner/safer than assigning to array.reindex. (Who knows, maybe that’ll be a method in JavaScript in the future.) I also tweaked the logic slightly to handle channel values specified as iterables (even though there’s a latent confusion in isOptions or isObject that I’m not fixing here).

@mbostock mbostock merged commit ad8600b into mbostock/exclusive-facets Aug 18, 2023
@mbostock mbostock deleted the fil/exclusive-facets-reindex branch August 18, 2023 21:00
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