From 8ab9e54a62eb2c63ef318c56e5600ba35d0500fa Mon Sep 17 00:00:00 2001 From: junlu592 Date: Wed, 10 Dec 2025 12:49:40 +0100 Subject: [PATCH] bin merging logic removed, since totals are correctly calculated anyways --- ts/routes/graphs/reviews.ts | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/ts/routes/graphs/reviews.ts b/ts/routes/graphs/reviews.ts index 933f56d20..f40b532e4 100644 --- a/ts/routes/graphs/reviews.ts +++ b/ts/routes/graphs/reviews.ts @@ -133,24 +133,12 @@ export function renderReviews( } const sourceMap = showTime ? sourceData.reviewTime : sourceData.reviewCount; + // Create bins using the thresholds: each bin contains data points between consecutive thresholds let bins = bin() - .value((m) => m[0]) - .domain(x.domain() as any) - .thresholds(thresholds)(sourceMap.entries() as any); + .value((m) => m[0]) // Extract the day number from each map entry [day, data] + .domain(x.domain() as any) // Bins are constrained to this domain [xMin, xMax] + .thresholds(thresholds)(sourceMap.entries() as any); // Use computed thresholds to split data into bins - if (bins.length > 1 && thresholds.length > 1) { - const lastBin = bins[bins.length - 1]; - const prevBin = bins[bins.length - 2]; - const nominalWidth = thresholds[1] - thresholds[0]; - const lastWidth = lastBin.x1! - lastBin.x0!; - if (lastBin.x1! > 0 && lastWidth < nominalWidth * 0.75) { - for (const entry of lastBin) { - prevBin.push(entry); - } - prevBin.x1 = lastBin.x1; - bins = bins.slice(0, -1); - } - } // empty graph? const totalDays = sum(bins, (bin) => bin.length);