Skip to content

Commit 1a85201

Browse files
committed
fix(frontend/utils): ensure resampled items are properly sorted
Sort "by" insertion order of `Map` is not enough in all for IP subnet view, so sort items properly after resampling.
1 parent 989790a commit 1a85201

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

frontend/src/utils/commonCharts.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export function resampleTimedData(data, dtKey, unitCount, unit, reduceFn) {
7272
return []
7373
}
7474

75-
// Map to guarantee insertion order
75+
// Map instead of object to allow for `Date` keys
7676
let buckets = new Map()
7777

7878
// Split data into buckets
@@ -90,5 +90,7 @@ export function resampleTimedData(data, dtKey, unitCount, unit, reduceFn) {
9090
let bucketDt = new Date(key)
9191
result.push(...reduceFn(bucket, bucketDt).map((item) => ({ [dtKey]: bucketDt, ...item })))
9292
}
93-
return result
93+
94+
// Ensure correct order of buckets
95+
return result.sort((a, b) => a[dtKey] - b[dtKey])
9496
}

0 commit comments

Comments
 (0)