From 97dd99f4a11360c4243684b24038bb2e85856d8b Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 19 Nov 2022 10:53:15 +0100 Subject: [PATCH] Fix bins odd beavior if only one trade is present --- src/shared/charts/binCount.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/shared/charts/binCount.ts b/src/shared/charts/binCount.ts index 0a10b317..b9a05903 100644 --- a/src/shared/charts/binCount.ts +++ b/src/shared/charts/binCount.ts @@ -8,11 +8,13 @@ export function binData(data: number[], bins: number) { Math.round((minimum + i * binSize) * 1000) / 1000, 0, ]); + // console.log(baseBins); for (let i = 0; i < data.length; i++) { const index = Math.min(Math.floor((data[i] - minimum) / binSize), bins - 1); - // console.log(data[i], index) - baseBins[index][1]++; + if (!isNaN(index)) { + baseBins[index][1]++; + } } return baseBins;