Skip to content

Commit 786ea07

Browse files
committed
fix: tooltip secondary axis stable sort
1 parent 3c36b18 commit 786ea07

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/components/Chart.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -796,12 +796,14 @@ function sortDatumsBySecondaryPx<TDatum>(
796796
const bPx =
797797
bAxis?.scale(bAxis.stacked ? b.stackData?.[1] : b.secondaryValue) ?? NaN
798798

799-
return aPx > bPx
800-
? 1
801-
: aPx < bPx
802-
? -1
803-
: a.seriesIndex > b.seriesIndex
804-
? 1
805-
: -1
799+
if ((aAxis || bAxis)?.stacked) {
800+
return a.seriesIndex > b.seriesIndex
801+
? 1
802+
: a.seriesIndex < b.seriesIndex
803+
? -1
804+
: 0
805+
}
806+
807+
return aPx > bPx ? 1 : aPx < bPx ? -1 : 0
806808
})
807809
}

0 commit comments

Comments
 (0)