Fix bins odd beavior if only one trade is present

This commit is contained in:
Matthias 2022-11-19 10:53:15 +01:00
parent 91c352f090
commit 97dd99f4a1

View File

@ -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;