#043 style light mobile: high Scientific & Data Journalism

Empirical Data Atlas

Institutional empirical research portal with multi-series longitudinal charts, linear/log switches, and data tables.

Inspired by Our World in Data ↗

Download .html
Fullscreen ↗

WHY THIS AESTHETIC IS UNIQUE

Prioritizes transparent empirical evidence by pairing authoritative Oxford-navy editorial framing with interactive chart/table explorers that cite methodology directly beneath each plot.

BEST FOR

Public policy and longitudinal research portalsClimate, energy, and demographic open-data explorersAnnual transparency and impact reports

TAGS

COLOR PALETTE (CLICK TO COPY HEX)

TYPOGRAPHY

Display
Playfair Display
Body
Lato
Mono
IBM Plex Mono
Scale
Editorial serif titles (28-38px) paired with clean humanist sans UI controls (13-15px) and tabular monospace axis labels.

Google Fonts Stylesheet ↗

ARCHITECTURE & MOBILE NOTES

LAYOUT

Institutional top bar in Oxford navy above a centered interactive grapher card with bottom Chart/Table mode tabs, source footer, and country legend chips.

INTERACTION

Toggle individual series visibility, switch between Linear and Logarithmic Y-axis scales, and flip seamlessly between SVG time-series chart and sortable tabular data.

MOBILE

Country legend wraps into scrollable 44px touch chips and the data table scrolls cleanly inside its card container with zero page overflow.

AI AGENT GUARDRAILS

DO

  • Include explicit units, source attribution, and axis labels on every chart
  • Provide both visual chart and structured table views for the same underlying dataset
  • Use distinct, colorblind-conscious series hues against crisp white chart surfaces

DON'T

  • Do not omit zero-baseline or scale indicators when toggling Linear vs Log modes
  • Do not clutter the grapher with decorative 3D effects or unlabelled sparklines
STANDALONE SOURCE · demos/empirical-data-atlas.html (24.7 KB)
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Global Empirical Atlas — Share of Electricity from Renewables (1990–2025)</title>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Playfair+Display:wght@600;700&family=Source+Sans+3:wght@400;500;600;700&display=swap" rel="stylesheet">
  <style>
    :root {
      --canvas: #F7F9FB;
      --surface: #FFFFFF;
      --ink: #0F2744;
      --accent: #1D5B9B;
      --accent-soft: #EBF3FA;
      --muted: #5C6F82;
      --border: #DCE4EC;
      --serif: 'Playfair Display', Georgia, serif;
      --sans: 'Source Sans 3', system-ui, -apple-system, sans-serif;
      --mono: 'IBM Plex Mono', ui-monospace, monospace;
    }

    *, *::before, *::after {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      background: var(--canvas);
      color: var(--ink);
      font-family: var(--sans);
      line-height: 1.55;
      overflow-x: hidden;
    }

    /* Institutional Header */
    .inst-header {
      background: var(--ink);
      color: #FFFFFF;
      border-bottom: 3px solid var(--accent);
    }

    .inst-inner {
      max-width: 1180px;
      margin: 0 auto;
      padding: 0 20px;
      min-height: 62px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
    }

    .inst-brand {
      display: flex;
      align-items: center;
      gap: 12px;
      text-decoration: none;
      color: #FFFFFF;
    }

    .inst-mark {
      width: 34px;
      height: 34px;
      border-radius: 4px;
      background: var(--accent);
      display: grid;
      place-items: center;
      font-family: var(--serif);
      font-weight: 700;
      font-size: 1.05rem;
      flex-shrink: 0;
    }

    .inst-title {
      font-weight: 700;
      font-size: 1rem;
      letter-spacing: 0.01em;
      line-height: 1.15;
    }

    .inst-sub {
      display: block;
      font-size: 0.72rem;
      color: #A9BFD4;
      font-weight: 400;
    }

    .inst-nav {
      display: flex;
      align-items: center;
      gap: 20px;
      font-size: 0.9rem;
    }

    .inst-nav a {
      color: #D7E4F0;
      text-decoration: none;
      font-weight: 500;
    }

    .inst-nav a:hover {
      color: #FFFFFF;
      text-decoration: underline;
    }

    .nav-menu-btn {
      display: none;
      min-width: 44px;
      min-height: 44px;
      padding: 0 12px;
      background: rgba(255, 255, 255, 0.12);
      border: 1px solid rgba(255, 255, 255, 0.25);
      border-radius: 5px;
      color: #FFFFFF;
      font-family: var(--sans);
      font-weight: 600;
      cursor: pointer;
    }

    .mobile-nav-drawer {
      display: none;
      background: #133154;
      padding: 8px 20px 16px;
      border-top: 1px solid rgba(255, 255, 255, 0.12);
    }

    .mobile-nav-drawer.open {
      display: block;
    }

    .mobile-nav-drawer a {
      display: flex;
      align-items: center;
      min-height: 44px;
      color: #E4EEF7;
      text-decoration: none;
      border-bottom: 1px solid rgba(255, 255, 255, 0.08);
      font-size: 0.95rem;
    }

    /* Main Container */
    .page-shell {
      max-width: 1180px;
      margin: 0 auto;
      padding: 28px 20px 64px;
    }

    .breadcrumb {
      font-size: 0.82rem;
      color: var(--muted);
      margin-bottom: 10px;
    }

    .page-head h1 {
      font-family: var(--serif);
      font-size: clamp(1.7rem, 3.2vw, 2.45rem);
      line-height: 1.18;
      margin: 0 0 10px;
      color: var(--ink);
    }

    .page-lead {
      max-width: 74ch;
      color: var(--muted);
      font-size: 1.04rem;
      margin: 0 0 24px;
    }

    /* KPI Summary Strip */
    .kpi-strip {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 14px;
      margin-bottom: 24px;
    }

    .kpi-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 14px 16px;
    }

    .kpi-label {
      font-size: 0.76rem;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--muted);
      font-weight: 600;
    }

    .kpi-value {
      font-family: var(--mono);
      font-size: 1.45rem;
      font-weight: 500;
      color: var(--ink);
      margin: 4px 0 2px;
    }

    .kpi-delta {
      font-size: 0.8rem;
      color: var(--accent);
      font-weight: 600;
    }

    /* Grapher Card */
    .grapher-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      box-shadow: 0 4px 18px rgba(15, 39, 68, 0.05);
      overflow: hidden;
    }

    .grapher-top {
      padding: 20px 22px 14px;
      border-bottom: 1px solid var(--border);
      display: flex;
      flex-wrap: wrap;
      align-items: flex-start;
      justify-content: space-between;
      gap: 14px;
    }

    .grapher-title {
      font-family: var(--serif);
      font-size: 1.28rem;
      margin: 0 0 4px;
    }

    .grapher-sub {
      font-size: 0.88rem;
      color: var(--muted);
      margin: 0;
    }

    .grapher-controls {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
    }

    .seg-group {
      display: inline-flex;
      background: var(--canvas);
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 2px;
    }

    .seg-btn {
      min-height: 40px;
      padding: 0 13px;
      border: none;
      background: transparent;
      color: var(--muted);
      font-family: var(--sans);
      font-size: 0.84rem;
      font-weight: 600;
      border-radius: 4px;
      cursor: pointer;
    }

    .seg-btn.active {
      background: var(--surface);
      color: var(--accent);
      box-shadow: 0 1px 3px rgba(15, 39, 68, 0.12);
    }

    /* Country Filter Chips */
    .country-bar {
      padding: 12px 22px;
      background: #FAFCFE;
      border-bottom: 1px solid var(--border);
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
    }

    .country-bar-label {
      font-size: 0.78rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--muted);
      margin-right: 4px;
    }

    .country-chip {
      min-height: 40px;
      padding: 0 12px;
      border-radius: 99px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--ink);
      font-family: var(--sans);
      font-size: 0.84rem;
      font-weight: 600;
      display: inline-flex;
      align-items: center;
      gap: 7px;
      cursor: pointer;
      transition: opacity 0.15s, border-color 0.15s;
    }

    .country-chip.inactive {
      opacity: 0.42;
    }

    .swatch {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      flex-shrink: 0;
    }

    /* Chart & Table Body */
    .grapher-body {
      padding: 18px 22px 22px;
    }

    .chart-wrap {
      position: relative;
      width: 100%;
    }

    #atlasSvg {
      width: 100%;
      height: auto;
      display: block;
    }

    .hover-readout {
      margin-top: 12px;
      padding: 10px 14px;
      background: var(--canvas);
      border: 1px solid var(--border);
      border-radius: 6px;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      font-size: 0.86rem;
    }

    .hover-year {
      font-family: var(--mono);
      font-weight: 600;
      color: var(--accent);
    }

    .hover-values {
      display: flex;
      flex-wrap: wrap;
      gap: 14px;
      font-family: var(--mono);
      font-size: 0.8rem;
    }

    .table-wrap {
      display: none;
      width: 100%;
      overflow-x: auto;
    }

    .table-wrap.active {
      display: block;
    }

    .chart-panel.hidden {
      display: none;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.9rem;
    }

    th, td {
      padding: 11px 12px;
      text-align: right;
      border-bottom: 1px solid var(--border);
      font-variant-numeric: tabular-nums;
    }

    th:first-child, td:first-child {
      text-align: left;
      font-weight: 600;
    }

    thead th {
      background: var(--canvas);
      color: var(--muted);
      font-size: 0.78rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }

    .grapher-footer {
      padding: 14px 22px;
      background: var(--canvas);
      border-top: 1px solid var(--border);
      font-size: 0.8rem;
      color: var(--muted);
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      gap: 8px;
    }

    /* Methodology Notes */
    .notes-grid {
      margin-top: 28px;
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 18px;
    }

    .note-box {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 18px 20px;
    }

    .note-box h2 {
      font-family: var(--serif);
      font-size: 1.12rem;
      margin: 0 0 8px;
    }

    .note-box p {
      margin: 0;
      font-size: 0.92rem;
      color: var(--muted);
    }

    @media (max-width: 820px) {
      .inst-nav {
        display: none;
      }

      .nav-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
      }

      .kpi-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .notes-grid {
        grid-template-columns: 1fr;
      }

      .seg-btn, .country-chip {
        min-height: 44px;
      }

      .grapher-top, .country-bar, .grapher-body, .grapher-footer {
        padding-left: 14px;
        padding-right: 14px;
      }
    }
  </style>
</head>
<body>
  <header class="inst-header">
    <div class="inst-inner">
      <a class="inst-brand" href="#top">
        <span class="inst-mark" aria-hidden="true">E</span>
        <div>
          <span class="inst-title">Empirical Data Atlas</span>
          <span class="inst-sub">Institute for Global Quantitative Research</span>
        </div>
      </a>
      <nav class="inst-nav" aria-label="Primary portal navigation">
        <a href="#explorer">Data Explorer</a>
        <a href="#methodology">Methodology</a>
        <a href="#sources">Sources</a>
      </nav>
      <button class="nav-menu-btn" id="menuToggle" type="button" aria-expanded="false" aria-controls="mobileDrawer">Menu</button>
    </div>
    <nav class="mobile-nav-drawer" id="mobileDrawer" aria-label="Mobile navigation">
      <a href="#explorer">Data Explorer</a>
      <a href="#methodology">Methodology</a>
      <a href="#sources">Sources &amp; Citations</a>
    </nav>
  </header>

  <main class="page-shell" id="top">
    <div class="breadcrumb">Energy &amp; Environment / Electricity Mix / Renewable Generation</div>
    <section class="page-head">
      <h1>Share of Electricity Generation from Renewables, 1990–2025</h1>
      <p class="page-lead">
        Percentage of total gross electricity generated from hydropower, solar photovoltaic, onshore and offshore wind, geothermal, and bioenergy across major economies.
      </p>
    </section>

    <section class="kpi-strip" aria-label="Headline global statistics">
      <div class="kpi-card">
        <div class="kpi-label">World Share (2025)</div>
        <div class="kpi-value">34.8%</div>
        <div class="kpi-delta">+15.6 pp since 2000</div>
      </div>
      <div class="kpi-card">
        <div class="kpi-label">Denmark (2025)</div>
        <div class="kpi-value">86.4%</div>
        <div class="kpi-delta">Wind-led grid leader</div>
      </div>
      <div class="kpi-card">
        <div class="kpi-label">Germany (2025)</div>
        <div class="kpi-value">58.2%</div>
        <div class="kpi-delta">+54.6 pp since 1990</div>
      </div>
      <div class="kpi-card">
        <div class="kpi-label">China (2025)</div>
        <div class="kpi-value">36.9%</div>
        <div class="kpi-delta">Largest absolute TWh</div>
      </div>
    </section>

    <section class="grapher-card" id="explorer" aria-label="Interactive renewable electricity explorer">
      <div class="grapher-top">
        <div>
          <h2 class="grapher-title">Renewable Share of Electricity Production (%)</h2>
          <p class="grapher-sub">Annual series, 1990 to 2025 · Hover or tap year columns to inspect exact values</p>
        </div>
        <div class="grapher-controls">
          <div class="seg-group" role="group" aria-label="Vertical axis scale">
            <button class="seg-btn active" type="button" data-scale="linear">Linear</button>
            <button class="seg-btn" type="button" data-scale="log">Log</button>
          </div>
          <div class="seg-group" role="group" aria-label="Data view mode">
            <button class="seg-btn active" type="button" data-view="chart">Chart</button>
            <button class="seg-btn" type="button" data-view="table">Table</button>
          </div>
        </div>
      </div>

      <div class="country-bar" id="countryBar" role="group" aria-label="Toggle countries in chart">
        <span class="country-bar-label">Entities:</span>
      </div>

      <div class="grapher-body">
        <div class="chart-panel" id="chartPanel">
          <div class="chart-wrap">
            <svg id="atlasSvg" viewBox="0 0 860 390" role="img" aria-label="Multi-country renewable electricity share time series from 1990 to 2025"></svg>
          </div>
          <div class="hover-readout" aria-live="polite">
            <span class="hover-year" id="hoverYear">YEAR: 2025</span>
            <div class="hover-values" id="hoverValues"></div>
          </div>
        </div>

        <div class="table-wrap" id="tablePanel">
          <table>
            <thead>
              <tr>
                <th>Entity</th>
                <th>1990</th>
                <th>2000</th>
                <th>2010</th>
                <th>2020</th>
                <th>2025</th>
                <th>Change (pp)</th>
              </tr>
            </thead>
            <tbody id="atlasTableBody"></tbody>
          </table>
        </div>
      </div>

      <div class="grapher-footer" id="sources">
        <span><strong>Data source:</strong> Ember Global Electricity Review &amp; Energy Institute Statistical Review (2026 release)</span>
        <span>CC BY 4.0 · Empirical Data Atlas</span>
      </div>
    </section>

    <section class="notes-grid" id="methodology">
      <div class="note-box">
        <h2>Measurement Definition</h2>
        <p>
          Renewables include hydropower, wind, solar PV, concentrated solar power, geothermal, wave/tidal, and modern biomass electricity. Nuclear power is excluded from this indicator and tracked separately under low-carbon generation.
        </p>
      </div>
      <div class="note-box">
        <h2>Interpreting Logarithmic Scale</h2>
        <p>
          Switching to the logarithmic Y-axis highlights exponential early-stage adoption—such as Denmark and Germany expanding from under 4% renewable electricity in 1990 to majority-renewable grids within three decades.
        </p>
      </div>
    </section>
  </main>

  <script>
    (() => {
      const YEARS = [1990, 1995, 2000, 2005, 2010, 2015, 2020, 2025];
      const SERIES = [
        { id: 'DNK', name: 'Denmark', color: '#1D5B9B', values: [3.2, 5.8, 16.4, 27.1, 31.9, 65.4, 81.2, 86.4], active: true },
        { id: 'BRA', name: 'Brazil', color: '#1B8A5A', values: [93.4, 92.8, 89.6, 86.2, 84.8, 75.5, 84.1, 88.9], active: true },
        { id: 'DEU', name: 'Germany', color: '#D97706', values: [3.6, 4.9, 6.6, 10.4, 17.1, 29.5, 44.6, 58.2], active: true },
        { id: 'CHN', name: 'China', color: '#C0392B', values: [20.4, 19.0, 16.6, 16.0, 18.4, 24.1, 28.4, 36.9], active: true },
        { id: 'USA', name: 'United States', color: '#6D28D9', values: [11.4, 10.7, 9.2, 8.8, 10.3, 13.4, 19.8, 25.6], active: true },
        { id: 'WLD', name: 'World', color: '#334155', values: [19.5, 19.3, 19.2, 18.4, 19.9, 23.1, 28.6, 34.8], active: true }
      ];

      let scaleMode = 'linear';
      let viewMode = 'chart';
      let selectedYearIdx = YEARS.length - 1;

      const svg = document.getElementById('atlasSvg');
      const countryBar = document.getElementById('countryBar');
      const hoverYear = document.getElementById('hoverYear');
      const hoverValues = document.getElementById('hoverValues');
      const tableBody = document.getElementById('atlasTableBody');

      function buildChips() {
        SERIES.forEach((s) => {
          const btn = document.createElement('button');
          btn.type = 'button';
          btn.className = 'country-chip';
          btn.innerHTML = `<span class="swatch" style="background:${s.color}"></span><span>${s.name}</span>`;
          btn.addEventListener('click', () => {
            s.active = !s.active;
            btn.classList.toggle('inactive', !s.active);
            renderChart();
            renderReadout();
          });
          countryBar.appendChild(btn);
        });
      }

      function yToPx(val, top, bottom) {
        if (scaleMode === 'log') {
          const minL = Math.log10(2);
          const maxL = Math.log10(100);
          const clamped = Math.max(2, Math.min(100, val));
          const norm = (Math.log10(clamped) - minL) / (maxL - minL);
          return bottom - norm * (bottom - top);
        }
        return bottom - (val / 100) * (bottom - top);
      }

      function renderChart() {
        const ns = 'http://www.w3.org/2000/svg';
        svg.innerHTML = '';

        const padL = 52;
        const padR = 112;
        const padT = 22;
        const padB = 42;
        const W = 860;
        const H = 390;
        const plotW = W - padL - padR;

        const yTicks = scaleMode === 'log' ? [2, 5, 10, 25, 50, 100] : [0, 20, 40, 60, 80, 100];

        // Horizontal grid & Y labels
        yTicks.forEach((tick) => {
          const y = yToPx(tick, padT, H - padB);
          const line = document.createElementNS(ns, 'line');
          line.setAttribute('x1', padL);
          line.setAttribute('x2', W - padR);
          line.setAttribute('y1', y);
          line.setAttribute('y2', y);
          line.setAttribute('stroke', '#E5ECF3');
          line.setAttribute('stroke-dasharray', tick === 0 ? '' : '3 3');
          svg.appendChild(line);

          const txt = document.createElementNS(ns, 'text');
          txt.setAttribute('x', padL - 10);
          txt.setAttribute('y', y + 4);
          txt.setAttribute('text-anchor', 'end');
          txt.setAttribute('font-size', '12');
          txt.setAttribute('fill', '#5C6F82');
          txt.setAttribute('font-family', 'IBM Plex Mono, monospace');
          txt.textContent = `${tick}%`;
          svg.appendChild(txt);
        });

        // X-axis labels & interactive year hit columns
        YEARS.forEach((yr, idx) => {
          const x = padL + (idx / (YEARS.length - 1)) * plotW;
          if (idx === selectedYearIdx) {
            const guide = document.createElementNS(ns, 'line');
            guide.setAttribute('x1', x);
            guide.setAttribute('x2', x);
            guide.setAttribute('y1', padT);
            guide.setAttribute('y2', H - padB);
            guide.setAttribute('stroke', '#1D5B9B');
            guide.setAttribute('stroke-opacity', '0.35');
            guide.setAttribute('stroke-width', '1.5');
            svg.appendChild(guide);
          }

          const lbl = document.createElementNS(ns, 'text');
          lbl.setAttribute('x', x);
          lbl.setAttribute('y', H - 14);
          lbl.setAttribute('text-anchor', 'middle');
          lbl.setAttribute('font-size', '12');
          lbl.setAttribute('fill', idx === selectedYearIdx ? '#0F2744' : '#5C6F82');
          lbl.setAttribute('font-weight', idx === selectedYearIdx ? '700' : '400');
          lbl.setAttribute('font-family', 'IBM Plex Mono, monospace');
          lbl.textContent = yr;
          svg.appendChild(lbl);
        });

        // Series polylines and end-labels
        const activeSeries = SERIES.filter((s) => s.active);
        activeSeries.forEach((s) => {
          const pts = s.values.map((v, idx) => {
            const x = padL + (idx / (YEARS.length - 1)) * plotW;
            const y = yToPx(v, padT, H - padB);
            return [x, y];
          });

          const path = document.createElementNS(ns, 'polyline');
          path.setAttribute('fill', 'none');
          path.setAttribute('stroke', s.color);
          path.setAttribute('stroke-width', s.id === 'WLD' ? '2.2' : '2.7');
          if (s.id === 'WLD') path.setAttribute('stroke-dasharray', '6 4');
          path.setAttribute('points', pts.map((p) => `${p[0].toFixed(1)},${p[1].toFixed(1)}`).join(' '));
          svg.appendChild(path);

          // Highlight dot on selected year
          const [sx, sy] = pts[selectedYearIdx];
          const dot = document.createElementNS(ns, 'circle');
          dot.setAttribute('cx', sx);
          dot.setAttribute('cy', sy);
          dot.setAttribute('r', '4.6');
          dot.setAttribute('fill', s.color);
          dot.setAttribute('stroke', '#FFFFFF');
          dot.setAttribute('stroke-width', '1.8');
          svg.appendChild(dot);

          // End label
          const [lx, ly] = pts[pts.length - 1];
          const endLbl = document.createElementNS(ns, 'text');
          endLbl.setAttribute('x', lx + 8);
          endLbl.setAttribute('y', ly + 4);
          endLbl.setAttribute('font-size', '12');
          endLbl.setAttribute('font-weight', '600');
          endLbl.setAttribute('fill', s.color);
          endLbl.textContent = `${s.name} ${s.values[s.values.length - 1]}%`;
          svg.appendChild(endLbl);
        });

        // Transparent interactive hover/tap bands
        const colW = plotW / (YEARS.length - 1);
        YEARS.forEach((yr, idx) => {
          const x = padL + idx * colW - colW / 2;
          const rect = document.createElementNS(ns, 'rect');
          rect.setAttribute('x', Math.max(padL, x));
          rect.setAttribute('y', padT);
          rect.setAttribute('width', colW);
          rect.setAttribute('height', H - padT - padB);
          rect.setAttribute('fill', 'transparent');
          rect.style.cursor = 'pointer';
          rect.addEventListener('mouseenter', () => {
            selectedYearIdx = idx;
            renderChart();
            renderReadout();
          });
          rect.addEventListener('click', () => {
            selectedYearIdx = idx;
            renderChart();
            renderReadout();
          });
          svg.appendChild(rect);
        });
      }

      function renderReadout() {
        hoverYear.textContent = `YEAR: ${YEARS[selectedYearIdx]}`;
        hoverValues.innerHTML = SERIES.filter((s) => s.active)
          .map((s) => `<span style="color:${s.color}"><strong>${s.id}</strong> ${s.values[selectedYearIdx].toFixed(1)}%</span>`)
          .join('');
      }

      function renderTable() {
        tableBody.innerHTML = SERIES.map((s) => {
          const delta = (s.values[7] - s.values[0]).toFixed(1);
          const sign = Number(delta) >= 0 ? '+' : '';
          return `
            <tr>
              <td><span class="swatch" style="display:inline-block;background:${s.color};margin-right:8px;"></span>${s.name}</td>
              <td>${s.values[0].toFixed(1)}%</td>
              <td>${s.values[2].toFixed(1)}%</td>
              <td>${s.values[4].toFixed(1)}%</td>
              <td>${s.values[6].toFixed(1)}%</td>
              <td><strong>${s.values[7].toFixed(1)}%</strong></td>
              <td style="color:${Number(delta) >= 0 ? '#1B8A5A' : '#C0392B'}">${sign}${delta} pp</td>
            </tr>`;
        }).join('');
      }

      document.querySelectorAll('[data-scale]').forEach((btn) => {
        btn.addEventListener('click', () => {
          document.querySelectorAll('[data-scale]').forEach((b) => b.classList.remove('active'));
          btn.classList.add('active');
          scaleMode = btn.dataset.scale;
          renderChart();
        });
      });

      document.querySelectorAll('[data-view]').forEach((btn) => {
        btn.addEventListener('click', () => {
          document.querySelectorAll('[data-view]').forEach((b) => b.classList.remove('active'));
          btn.classList.add('active');
          viewMode = btn.dataset.view;
          document.getElementById('chartPanel').classList.toggle('hidden', viewMode === 'table');
          document.getElementById('tablePanel').classList.toggle('active', viewMode === 'table');
        });
      });

      const menuToggle = document.getElementById('menuToggle');
      const mobileDrawer = document.getElementById('mobileDrawer');
      menuToggle.addEventListener('click', () => {
        const open = mobileDrawer.classList.toggle('open');
        menuToggle.setAttribute('aria-expanded', String(open));
      });

      buildChips();
      renderChart();
      renderReadout();
      renderTable();
    })();
  </script>
</body>
</html>