Skip to content

Commit

Permalink
fix: Reset sorting bar issue in Barchart (#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 Apr 13, 2022
1 parent 8e326af commit 94e06c2
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 94e06c2

Please sign in to comment.