Skip to content

Commit

Permalink
fix rank
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Nov 20, 2018
1 parent 04ce0d7 commit 415334d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/model/RankColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export default class RankColumn extends Column {
let offset = 0;
for (const group of groups) {
const rank = group.index2pos[row.i];
if (typeof rank === 'number' && !isNaN(rank)) {
return rank + 1 + offset; // starting with 1
if (typeof rank === 'number' && !isNaN(rank) && rank > 0) {
return rank + offset;
}
offset += group.order.length;
}
Expand Down
3 changes: 2 additions & 1 deletion src/provider/LocalDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ export default class LocalDataProvider extends ACommonDataProvider {
// initial no sorting required just index mapping
const order = chooseByLength(this._data.length);
order.set(range(this._data.length));
const index2pos = order.slice();
const index2pos = chooseByLength(this._data.length);
index2pos.set(range(1, this._data.length + 1));
return [Object.assign({order, index2pos}, defaultGroup)];
}

Expand Down
2 changes: 1 addition & 1 deletion src/provider/sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function sort2indices(arr: {i: number}[], rawLength: number) {
for (let i = 0; i < arr.length; ++i) {
const ri = arr[i].i;
order[i] = ri;
index2pos[ri] = i;
index2pos[ri] = i + 1; // shift by one
}
return {order, index2pos};
}
Expand Down

0 comments on commit 415334d

Please sign in to comment.