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

Sort By Set #358

Merged
merged 9 commits into from
May 13, 2024
Merged

Sort By Set #358

merged 9 commits into from
May 13, 2024

Conversation

JakeWags
Copy link
Member

@JakeWags JakeWags commented May 2, 2024

Does this PR close any open issues?

Closes #146

Give a longer description of what this PR addresses and why it's needed

This PR adds the ability to sort the UpSet plot by a set, aka, bringing a set to the top. See #113 for example context menu for sets.

The implemented behavior is based on the original Upset behavior here: http://vcg.github.io/upset/

This PR also removes any reference to the SortBy type, as this is only a string alias.

Provide pictures/videos of the behavior before and after these changes (optional)

BEFORE:
upset-sortbyset-before

AFTER:
upset-sortbyset-after

Have you added or updated relevant tests?

  • Yes
  • No changes are needed

Have you added or updated relevant documentation?

  • Yes
  • No changes are needed

Are there any additional TODOs before this PR is ready to go?

TODOs:

  • none

@JakeWags JakeWags requested a review from NateLanza May 2, 2024 18:31
@JakeWags JakeWags mentioned this pull request May 2, 2024
5 tasks
Copy link

netlify bot commented May 2, 2024

Deploy Preview for upset2 ready!

Name Link
🔨 Latest commit 0ccfdf9
🔍 Latest deploy log https://app.netlify.com/sites/upset2/deploys/664239d80da9b10008d3b031
😎 Deploy Preview https://deploy-preview-358--upset2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@JakeWags
Copy link
Member Author

JakeWags commented May 2, 2024

One point of discussion here is that I'd like to add tests for UpSet plot interactions such as aggregate, sort, etc; however, it doesn't seem like there is a good way to determine the order of the subsets on the plot, as their selectors are based on the position. Maybe adding an HTML id to each rendered row could be the solution to this.

@JakeWags
Copy link
Member Author

JakeWags commented May 2, 2024

One point of discussion here is that I'd like to add tests for UpSet plot interactions such as aggregate, sort, etc; however, it doesn't seem like there is a good way to determine the order of the subsets on the plot, as their selectors are based on the position. Maybe adding an HTML id to each rendered row could be the solution to this.

Addressed in ab1a972

Copy link
Contributor

@NateLanza NateLanza left a comment

Choose a reason for hiding this comment

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

A number of minor things that you can address if you feel the need; merge at your discretion. No blocking issues.

* @param sortBy - The set to sort by.
* @param vSetSortBy - The sort order for visible sets.
* @param visibleSets - The visible sets.
* @param sortByOrder - The sort order for the specified set. (optional)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this param no longer exists?


// combine the two sorted row lists
const sortedOrder = sortedSetMembers.order.concat(sortedNonSetMembers.order);
const sortedValues = { ...sortedSetMembers.values, ...sortedNonSetMembers.values };
Copy link
Contributor

Choose a reason for hiding this comment

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

Why use concat for one and spread/recombine for the other? If the goal is the same, same notation is more readable. Otherwise a comment explaining the implementation difference would be nice.

@@ -60,7 +60,8 @@ const sortByAction = registry.register(
'sort-by',
(state, { sort, sortByOrder }) => {
state.sortBy = sort;
state.sortByOrder = sortByOrder;
// should only be 'None' if sortBy is a Set
state.sortByOrder = sortByOrder || 'None';
Copy link
Contributor

Choose a reason for hiding this comment

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

I think using null instead of 'none' here is slightly more type-safe and makes sense semantically.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or does state.sortByOrder need to be a string?

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right that state.sortByOrder is a string. Using 'None' to me makes sense as there is no order for sorting by set.

@JakeWags JakeWags merged commit fd02989 into main May 13, 2024
7 checks passed
@JakeWags JakeWags deleted the 146-sort-by-set branch May 13, 2024 18:56
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.

Sort by set implementation
2 participants