-
Notifications
You must be signed in to change notification settings - Fork 185
descending order #1607
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
descending order #1607
Conversation
2d13457
to
04e993a
Compare
@@ -46,6 +45,7 @@ export * from "./cars-hexbin.js"; | |||
export * from "./cars-jitter.js"; | |||
export * from "./cars-mpg.js"; | |||
export * from "./cars-parcoords.js"; | |||
export * from "./channel-domain.js"; |
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.
I’m following the principle here that test names should indicate which features are being tested, rather than tests being feature-agnostic examples. We can have the latter, too, but here the tests are intended to test imputed channel domains so it’s better to call them that.
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.
As an aside, we can now do this if we need to use the raw grouped values for sorting (not that I'd recommend it, but…)
channels: {index: (d, i) => i},
sort: {
fy: "index",
reduce: (index) => index,
order: ([group, index]) => console.warn(Array.from(index, (i) => movies[i])) // replace with a comparator on ([groupA, indexA], [groupB, indexB])
}
Co-authored-by: Philippe Rivière <[email protected]>
* descending order * fix null order; add tests * Update src/channel.d.ts Co-authored-by: Philippe Rivière <[email protected]> --------- Co-authored-by: Philippe Rivière <[email protected]>
Instead of interpreting
reverse: true
as “sort by descending natural order”, the ChannelDomainOptions interface now has an order option which can be ascending, descending, or a comparator function (which compares two [name, value] tuples). This better matches the SortOrder interface, and enables two new features:order: null
you get input order (order of first occurrence in the data).reverse: true
you get true reverse order, putting null/unorderable values first when sorting, or reverse input order when not sorting, in the same manner as the basic sort transform.I’m leaving this as draft because we should probably add tests for both of these new features.Added tests!Fixes #1460. Ref. #1606 (comment)