From bb94dccfced8f44347bada0e8d10cc2a9fefdfb6 Mon Sep 17 00:00:00 2001 From: DEls Date: Tue, 27 Oct 2026 10:55:50 +0200 Subject: [PATCH] fix(sites): split certificate chart into certified invoice and retention Retention is about a tenth of the certified invoice, so on one shared scale its bars were barely visible and paired bars sat off their month labels. Each figure now gets its own chart and scale. Co-Authored-By: Claude Opus 5.5 --- .../sites/[id]/certificate-chart.tsx | 15 ++++---- .../dashboard/sites/[id]/site-detail-view.tsx | 37 +++++++++++++------ 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/app/dashboard/sites/[id]/certificate-chart.tsx b/src/app/dashboard/sites/[id]/certificate-chart.tsx index d20d31d..720880c 100644 --- a/src/app/dashboard/sites/[id]/certificate-chart.tsx +++ b/src/app/dashboard/sites/[id]/certificate-chart.tsx @@ -47,16 +47,19 @@ export function buildCertificateSeries( const money = (value: number) => `R${formatNumber(value, { notation: "compact", maximumFractionDigits: 1 })}`; -export function CertificateChart({ points }: { points: CertificatePoint[] }) { +/** One figure per chart: monthly bars against the left axis, running total line against the right. */ +export function CertificateChart({ points, metric }: { points: CertificatePoint[]; metric: "certified" | "retention" }) { + const color = metric === "certified" ? CERTIFIED_COLOR : RETENTION_COLOR; + const label = metric === "certified" ? "Certified invoice" : "Retention"; return ( -
+
{points.length === 0 ? (
No certificates imported yet.
) : ( - + format(parseISO(`${value}-01`), "MMM yy")} stroke="var(--muted-foreground)" tickLine={false} axisLine={false} fontSize={11} minTickGap={16} /> @@ -71,10 +74,8 @@ export function CertificateChart({ points }: { points: CertificatePoint[] }) { labelFormatter={(value) => format(parseISO(`${String(value)}-01`), "MMMM yyyy")} formatter={(value: number) => formatCurrency(value)} /> {value}} /> - - - - + + )} diff --git a/src/app/dashboard/sites/[id]/site-detail-view.tsx b/src/app/dashboard/sites/[id]/site-detail-view.tsx index 15c3d12..6307b7c 100644 --- a/src/app/dashboard/sites/[id]/site-detail-view.tsx +++ b/src/app/dashboard/sites/[id]/site-detail-view.tsx @@ -627,18 +627,31 @@ export function SiteDetailView({ data }: { data: SiteDetailData }) { - {/* Certified invoice & retention, monthly and cumulative */} - - - Certified invoice & retention -

- Bars show each month; lines show the running total (right axis). Certified invoice incl VAT, retention ex VAT. -

-
- - - -
+ {/* Certified invoice and retention, each monthly and cumulative */} +
+ + + Certified invoice (VAT incl) +

+ Bars: each month (left axis) · line: running total (right axis). +

+
+ + + +
+ + + Retention (ex VAT) +

+ Bars: each month (left axis) · line: running total (right axis). +

+
+ + + +
+
{/* PO commitments */} {data.poList.length > 0 && (