From a3fc69fe898f8d2019d0a16d5485fe7f6e7db115 Mon Sep 17 00:00:00 2001 From: junlu592 Date: Fri, 21 Nov 2025 12:52:51 +0100 Subject: [PATCH] oldest bin width modified to match other bins in reviews.ts --- ts/routes/graphs/reviews.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ts/routes/graphs/reviews.ts b/ts/routes/graphs/reviews.ts index 8302cb4c9..4f23698b7 100644 --- a/ts/routes/graphs/reviews.ts +++ b/ts/routes/graphs/reviews.ts @@ -110,7 +110,17 @@ export function renderReviews( } const desiredBars = Math.min(70, Math.abs(xMin!)); - const x = scaleLinear().domain([xMin!, xMax]); + let x = scaleLinear().domain([xMin!, xMax]); + let thresholds = x.ticks(desiredBars); + if (thresholds.length >= 2) { + const spacing = thresholds[1] - thresholds[0]; + const partial = thresholds[0] - x.domain()[0]; + if (spacing > 0 && partial > 0 && partial < spacing) { + const adjustedMin = thresholds[0] - spacing; + x = scaleLinear().domain([adjustedMin, xMax]); + thresholds = x.ticks(desiredBars); + } + } const sourceMap = showTime ? sourceData.reviewTime : sourceData.reviewCount; const bins = bin() @@ -118,7 +128,7 @@ export function renderReviews( return m[0]; }) .domain(x.domain() as any) - .thresholds(x.ticks(desiredBars))(sourceMap.entries() as any); + .thresholds(thresholds)(sourceMap.entries() as any); // empty graph? const totalDays = sum(bins, (bin) => bin.length);