"use client"; import type { ExploreResponse, FacilityStatus } from "@dci/core"; import { BarList, ColumnChart } from "@/components/ui/charts"; import { HonestEmpty } from "@/components/intelligence/shared"; import { fmtInt, fmtMw } from "@/lib/format"; import { STATUS_SHORT } from "@/lib/labels"; /** byStatus / byCountry / byYear charts over the whole filtered set (not the current page). */ export function ExploreCharts({ charts, entity, countryHrefBase }: { charts: ExploreResponse["charts"]; entity: "facilities" | "projects"; /** href prefix the iso2 is appended to (function props cannot cross the RSC boundary) */ countryHrefBase: string }) { const countryHref = (iso2: string) => `${countryHrefBase}${encodeURIComponent(iso2)}`; const byStatus = charts.byStatus.map((s) => ({ label: STATUS_SHORT[s.key as FacilityStatus] ?? s.key, value: s.count, secondary: s.mw })); const byYear = charts.byYear.filter((y) => y.year >= 1990 && y.year <= 2100).map((y) => ({ label: String(y.year), value: y.count, secondary: y.mw })); const byCountry = charts.byCountry.slice(0, 15); const mwTotal = charts.byStatus.reduce((a, s) => a + (s.mw ?? 0), 0); return (

By status

records{mwTotal > 0 ? ` · ${fmtMw(mwTotal)} published` : ""}
{byStatus.length ? (
fmtInt(v)} height={160} ariaLabel="Records by lifecycle status" />
) : ( )} {byStatus.length > 0 && (
    {charts.byStatus.map((s) => (
  • {STATUS_SHORT[s.key as FacilityStatus] ?? s.key} {fmtInt(s.count)} · {s.mw === null ? "MW —" : fmtMw(s.mw)}
  • ))}
)}

{entity === "projects" ? "By expected opening year" : "By opening year"}

records
{byYear.length ? (
fmtInt(v)} height={160} color="var(--ink-2)" ariaLabel="Records by year" />
) : ( )}

Records without a published date are not charted.

By country

top {byCountry.length} · records · published MW
{byCountry.length ? ({ label: c.name, value: c.count, href: countryHref(c.key), secondary: c.mw === null ? "MW —" : fmtMw(c.mw) }))} format={(v) => fmtInt(v)} /> : }
); }