-
Notifications
You must be signed in to change notification settings - Fork 627
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 facet values in ascending order as default #2581
Conversation
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.
A few comments -- you can add sort: 'ascending' | 'descending'
.
I think you haven't npm run build:examples
.
src/compile/facet.ts
Outdated
cross: true | ||
}}: {}) | ||
} | ||
}, | ||
...(isCrossedFacet ? {sort: { | ||
...(hasRow && hasColumn ? {sort: { |
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.
You always produce sort
and order
so writing it this way is better:
{
sort: {
field: [].concat(
hasRow: ? [this.field(ROW, {expr: 'datum'})] : [],
hasColumn: ? [this.field(COLUMN, {expr: 'datum'})] : []
)
order: [].concat(
hasRow: ? [ (this.facet.row.header && this.facet.row.header.sort) || 'ascending'] : [],
hasColumn: ? [ ... ] : []
)
}
src/compile/layout/header.ts
Outdated
from: {data: model.getName(channel)}, | ||
sort: { | ||
field: field(layoutHeader.facetFieldDef, {expr: 'datum'}), | ||
order: 'ascending' |
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.
(facetFieldDef.header && facetFieldDef.header.sort) || 'ascending'
I just fix a minor thing in the declaration. Let's merge when test finishes running. |
Fix #2553
(As a future work, I think we should allow user to sort facet as they want.)