Skip to content

Commit

Permalink
fix: Reset sorting bar issue in Barchart (apache#19371)
Browse files Browse the repository at this point in the history
* fix: Reset sorting bar issue in Barchart

* improving performance

* fix lint error
  • Loading branch information
codemaster08240328 authored and philipher29 committed Jun 9, 2022
1 parent 2244d50 commit 36fede4
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,11 @@ function nvd3Vis(element, props) {
chart.stacked(isBarStacked);
if (orderBars) {
data.forEach(d => {
d.values.sort((a, b) => (tryNumify(a.x) < tryNumify(b.x) ? -1 : 1));
const newValues = [...d.values]; // need to copy values to avoid redux store changed.
// eslint-disable-next-line no-param-reassign
d.values = newValues.sort((a, b) =>
tryNumify(a.x) < tryNumify(b.x) ? -1 : 1,
);
});
}
if (!reduceXTicks) {
Expand Down

0 comments on commit 36fede4

Please sign in to comment.