Planner and Explorer results: carbon footprint per FTE chart (#2071)¶
Ask¶
The Results page pairs the "Unit carbon footprint" category chart with a narrower "My unit carbon footprint per FTE" stacked bar on its right third. The Explorer and the Project Planner results cards only had the category chart. Add the per-FTE chart to both, in the same layout.
What the backend already provides¶
Nothing changed server-side. derive_report_sections
(backend/app/utils/report_stats.py) writes per_fte for every bucket
into each report's persisted stats, and merge_report_stats re-derives it
for the planner's summed years (summed kg over summed FTE). Simulator
reports have no validation step, so _build_report_stats counts every
active module as validated there and toEmissionBreakdown
(frontend/src/utils/emissionStatsAdapter.ts) keeps every active
bucket in per_person_breakdown. FTE comes from each report's own
Headcount module, which both the Explorer and the Planner carry.
Change (frontend only)¶
- Shared layout. The Results page's scoped
.results-charts-gridrules move tofrontend/src/css/03-layout/_grid.scssas.charts-grid(__main2 :__side1 from 1024px, stacked below). The Results page now uses the shared classes; the Explorer and Planner results cards wrap their main chart and the newCarbonFootPrintPerPersonChartin it. - Shared toggle. The per-FTE chart must show the same categories as
the main chart, so the results title row of both pages carries the
Calculator's "Additional data"
q-toggle(results_additional_data), right-aligned and vertically centred, and passes it to every chart asviewAdditionalData. A chart given that prop hides its own checkbox (ModuleCarbonFootprintChartalready did;PlannerGrantComparisonChartgained the prop). The Results page keeps its page-level filter. - Total follows the toggle.
sumBreakdownTonnestakes anincludeAdditionalflag: module categories only by default (what the chart draws), plus the additional rows when the toggle is on. Its old fallback to the backend's all-buckets total is gone: it showed a non-zero headline above an empty chart for a headcount-only sandbox. The print composables keep the default. - Planner bars.
CarbonFootPrintPerPersonCharttakes an optionalrowsprop (label + per-FTE values +hatched) in place of the single "My unit" bar, and now builds its bars from explicit per-bar data instead of an ECharts dataset so a bar can carry its own decal. The disabled EPFL-reference and objective rows went with the dataset.plannerPerFteRows(utils/plannerPerFte.ts) gives the Planner one bar per results view that has headcount, labelled and hatched exactly like the comparison chart's series (YEARS_DECAL, now inconstant/charts): "Grant proposal (range)" plain and "Detailed per year (range)" hatched for a grant plan with year sections, one plain bar otherwise. All bars share the one "Total" tick as side-by-side stacks; with several bars a legend names them and the tooltip shows one section per bar (its label and total, then its categories), like the comparison chart's tooltip (TooltipRow.heading). - Comparison chart card.
PlannerGrantComparisonChartnow renders the same card, header and download footer asModuleCarbonFootprintChart, so the planner's results chart reads like the explorer's; the print page dropped its extra wrapper card. - PDFs. Both print reports draw the per-FTE chart under the results
chart (horizontal bars, print mode), only when there is headcount. The
download link carries the page's toggle as
?additional=1|0; the print composables read it and both the charts and the totals follow it. - Missing headcount. Simulator reports are never "validated", so the
chart gets
show-validation-placeholderwithplaceholder-variant="add": when no FTE was entered (total_fteis 0, or no Planner view has one) the placeholder card replaces the whole side panel, title included and edge to edge like the Results page's own card, reading "Add Headcount to see results / Please fill in this moduleā¦" (results_add_module_title/_message) instead of the "Validateā¦" wording. The chart card isflex: 1so it fills the side column.
Verified locally¶
Test unit 1 (ENAC-IT4R-TEST), principal test login. Explorer without
headcount: placeholder fills the right third. Plan per-fte-check
(2027): placeholder before any FTE, one "Detailed per year (2027)" bar
after adding staff and student rows, additional categories appearing when
the main chart's checkbox is ticked.
While verifying: a staff row (SIUS 51) added FTE but no commuting /
food / waste, a student row added both, in the Calculator as well.
seed_generic_factors.py reads INPUT_DATA/headcount_member_factors.csv
but the local INPUT_DATA folder held headcount_members_factors.csv
(plural), so seed_all_factors printed its "Skipping factor seed" line
and the member factors were never loaded. Seeding that file for the
member type (2025 and 2026) fixed it: a staff-only row now prices in
both simulators. Rows saved before the seed keep their zero until
re-saved. A local seed-data gap, not a frontend issue; the silent skip in
the seeder is worth its own issue.
- Titles. The Explorer reuses the Results title ("My unit carbon
footprint per FTE"). The Planner gets
planner_results_per_fte_chart_title("{name} carbon footprint per FTE"), matching its neighbouring "{name} carbon footprint, year by year".
Out of scope¶
Nothing: the print totals now follow the same toggle as their charts.
Test¶
frontend/tests/unit/charts-additional-data.spec.ts mounts both main
charts with viewAdditionalData and checks they render no checkbox of
their own, and mounts the per-FTE chart without headcount to pin the
"add" placeholder wording. breakdown-total.spec.ts pins the helper:
module-only by default, additional rows on request, zero for a
headcount-only report with the toggle off.