-
Notifications
You must be signed in to change notification settings - Fork 185
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
Axes and grids now support the filter option #1665
Conversation
Got side tracked by a typescript issue: I want to remove the first and last ticks of an x axis (as in this D3 horizon chart), and for this I use the third argument ticks that the filter function is getting:
It works; however it's not documented: the function is typed as EDIT: this secondary remark is now addressed in #1670 |
…*, and *data* previously *data* was present in some cases (when going through the *arraytype*.map code path) but not others (e.g. when doing type conversion) Addresses this comment in #1665 (comment)
the secondary remark is discussed in #1670 and is not blocking for this PR. |
rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any context on what the problem was/what you had to change to get it working?
The PR’s description is now a bit more explicit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the context. It also helped to hide the whitespace in the diff.
Could we also support sort and reverse by applying them after the axis initializer, like we do for filter? Couldn’t we compose them using the same strategy that the initializer
does, just after the axis initializer instead of before? Something like this…
i.initializer = composeInitializer(i.initializer, initializer({filter, sort, reverse}).initializer);
or even shorter
i.initializer = initializer({filter, sort, reverse}, i.initializer).initializer;
* Axes and grids now support {filter, sort, reverse} closes observablehq#1457 closes observablehq#1655
The data for the axis and grid marks (the associated scale’s ticks) is computed (in the general case) after the scales have been initialized. As a consequence,
In this PR, by moving the filter logic to their initializer function, we allow the user to filter the axis ticks; for example in usStatePopulationDiverging, to draw ticks on the right only for states with a population decrease, and on the left only for states with a population increase. We also throw a proper error message when the sort and reverse options are specified.
closes #1457
closes #1655