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

improve arranged bar handling #268

Open
wants to merge 5 commits into
base: dev-v1.11.7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,121 changes: 595 additions & 526 deletions build/webcharts.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions build/webcharts.min.js

Large diffs are not rendered by default.

30 changes: 18 additions & 12 deletions src/chart/draw/consolidateData/transformData/makeNest.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,24 @@ export default function makeNest(mark, entries, sublevel) {
if (sublevel) {
this_nest.key(d => d[sublevel]);
this_nest.sortKeys((a, b) => {
return this.config.x.type === 'time'
? ascending(new Date(a), new Date(b))
: this.config.x.order
? ascending(this.config.x.order.indexOf(a), this.config.x.order.indexOf(b))
: sublevel === this.config.color_by && this.config.legend.order
? ascending(
this.config.legend.order.indexOf(a),
this.config.legend.order.indexOf(b)
)
: this.config.x.type === 'ordinal' || this.config.y.type === 'ordinal'
? naturalSorter(a, b)
: ascending(+a, +b);
let sort;

if (this.config.x.type === 'time') {
sort = ascending(new Date(a), new Date(b));
} else if (this.config.x.order) {
sort = ascending(this.config.x.order.indexOf(a), this.config.x.order.indexOf(b));
} else if (sublevel === this.config.color_by && this.config.legend.order) {
sort = ascending(
this.config.legend.order.indexOf(a),
this.config.legend.order.indexOf(b)
);
} else if (this.config.x.type === 'ordinal' || this.config.y.type === 'ordinal') {
sort = naturalSorter(a, b);
} else {
sort = ascending(+a, +b);
}

return sort;
});
}
this_nest.rollup(r => {
Expand Down
Loading