Skip to content

Commit

Permalink
fix: duplicate sorting in stack (#9213)
Browse files Browse the repository at this point in the history
try to close #8033,

avoid duplicate field by
```
          if (!s.field.includes(field)) {
            s.field.push(field);
            s.order.push(sortOrder);
          }
```

---------

Co-authored-by: GitHub Actions Bot <[email protected]>
  • Loading branch information
ChiaLingWeng and GitHub Actions Bot authored Dec 21, 2023
1 parent fa225a9 commit 3e35dc2
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
Binary file modified examples/compiled/arc_radial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 1 addition & 4 deletions examples/compiled/arc_radial.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@
"type": "stack",
"groupby": [],
"field": "data",
"sort": {
"field": ["data", "data"],
"order": ["ascending", "ascending"]
},
"sort": {"field": ["data"], "order": ["ascending"]},
"as": ["data_start", "data_end"],
"offset": "zero"
},
Expand Down
Binary file modified examples/compiled/layer_arc_label.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 1 addition & 4 deletions examples/compiled/layer_arc_label.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@
"type": "stack",
"groupby": [],
"field": "value",
"sort": {
"field": ["category", "category"],
"order": ["ascending", "ascending"]
},
"sort": {"field": ["category"], "order": ["ascending"]},
"as": ["value_start", "value_end"],
"offset": "zero"
},
Expand Down
6 changes: 4 additions & 2 deletions src/compile/data/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ export class StackNode extends DataFlowNode {
// FIXME is the default here correct for binned fields?
sort = stackby.reduce(
(s, field) => {
s.field.push(field);
s.order.push(sortOrder);
if (!s.field.includes(field)) {
s.field.push(field);
s.order.push(sortOrder);
}
return s;
},
{field: [], order: []}
Expand Down

0 comments on commit 3e35dc2

Please sign in to comment.