From e3546ea496f5d5dfd99aecd309212ca71d848b23 Mon Sep 17 00:00:00 2001 From: junlu592 Date: Fri, 21 Nov 2025 15:32:16 +0100 Subject: [PATCH] modified youngest bar in reviews to include today aswell --- ts/routes/graphs/reviews.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ts/routes/graphs/reviews.ts b/ts/routes/graphs/reviews.ts index 4f23698b7..35deeb81c 100644 --- a/ts/routes/graphs/reviews.ts +++ b/ts/routes/graphs/reviews.ts @@ -123,13 +123,27 @@ export function renderReviews( } const sourceMap = showTime ? sourceData.reviewTime : sourceData.reviewCount; - const bins = bin() + let bins = bin() .value((m) => { return m[0]; }) .domain(x.domain() as any) .thresholds(thresholds)(sourceMap.entries() as any); + 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); if (!totalDays) { @@ -219,8 +233,8 @@ export function renderReviews( } function tooltipText(d: BinType, cumulative: number): string { - const startDay = Math.trunc(d.x0!); - const endDay = Math.trunc(d.x1!); + const startDay = Math.floor(d.x0!); + const endDay = Math.ceil(d.x1!); const day = dayLabel(startDay, endDay); const totals = totalsForBin(d); const dayTotal = valueLabel(sum(totals));