mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-30 12:55:02 +00:00
fix(reporting): show scenario bars for EPC bands absent from the baseline
The breakdown chart looped only over baseline bands (epcBands), which the query returns only for bands that have properties. So a band reached ONLY after the scenario — e.g. A/B when no property starts that high — had no row, and its scenario bar never rendered (portfolio 812: scenario yields 7 A + 2 B, baseline has none). Iterate a canonical A–G+Unknown order over baseline ∪ scenario instead, so post-scenario-only bands still appear. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7de48448c0
commit
eef9fdc171
1 changed files with 16 additions and 4 deletions
|
|
@ -51,15 +51,27 @@ export function BreakdownChart({
|
|||
|
||||
const rows: any[] = [];
|
||||
|
||||
for (const d of epcBands) {
|
||||
const epc = d.epc ?? "Unknown";
|
||||
// The baseline query only returns bands that have properties, so a band
|
||||
// reached ONLY after the scenario (e.g. A/B when nothing starts that high)
|
||||
// is absent from epcBands — looping it alone drops those scenario bars.
|
||||
// Iterate a canonical order over baseline ∪ scenario instead.
|
||||
const baselineByBand = new Map(
|
||||
epcBands.map((d) => [d.epc ?? "Unknown", d]),
|
||||
);
|
||||
const BAND_ORDER = ["A", "B", "C", "D", "E", "F", "G", "Unknown"];
|
||||
const presentBands = BAND_ORDER.filter(
|
||||
(b) => baselineByBand.has(b) || (scenarioEpcBands?.[b] ?? 0) > 0,
|
||||
);
|
||||
|
||||
for (const epc of presentBands) {
|
||||
const d = baselineByBand.get(epc);
|
||||
const scenarioValue = scenarioEpcBands?.[epc] ?? 0;
|
||||
|
||||
// Baseline (stacked)
|
||||
rows.push({
|
||||
label: `${epc}`,
|
||||
[friendlyKeys.actual]: d.actual ?? 0,
|
||||
[friendlyKeys.estimated]: d.estimated ?? 0,
|
||||
[friendlyKeys.actual]: d?.actual ?? 0,
|
||||
[friendlyKeys.estimated]: d?.estimated ?? 0,
|
||||
[friendlyKeys.scenario]: 0,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue