Skip to content

Commit 94eb88d

Browse files
refactor: explicitly sort bid edge points by price in ascending order for chart rendering.
1 parent eba9649 commit 94eb88d

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/components/Dashboard/Chart/depthCanvas.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,15 @@ export function drawDepthChart(
196196
? (stats.bestBid + stats.bestAsk) / 2
197197
: price ?? 0;
198198

199-
const bidEdgePts = visibleBids.length > 0
199+
// 买方:按价格升序排列(从左到右),累积量从大到小
200+
const sortedBids = [...visibleBids].reverse();
201+
const bidEdgePts = sortedBids.length > 0
200202
? [
201-
{ price: priceRange.min, cumVolume: visibleBids[0].cumVolume },
202-
...visibleBids,
203+
{ price: priceRange.min, cumVolume: sortedBids[0].cumVolume },
204+
...sortedBids,
203205
{ price: dynamicMid, cumVolume: 0 },
204206
]
205-
: visibleBids;
207+
: sortedBids;
206208
const askEdgePts = visibleAsks.length > 0
207209
? [
208210
{ price: dynamicMid, cumVolume: 0 },

0 commit comments

Comments
 (0)