You are here

LA Population Growth

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Louisiana Population Growth (1910–2020)</title>
  <script src="https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.js"></script>
  <link href="https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.css" rel="stylesheet" />
  <style>
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      background: #0b0716;
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
      color: #f8fafc;
      overflow: hidden;
    }
    #map { position: fixed; inset: 0; width: 100vw; height: 100vh; }

    /* Top Editorial Header & Growth Telemetry */
    #hud-top {
      position: fixed;
      top: 28px;
      left: 36px;
      right: 36px;
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      pointer-events: none;
      z-index: 20;
    }
    .title-card {
      background: rgba(20, 10, 40, 0.90);
      backdrop-filter: blur(10px);
      border: 1px solid rgba(253, 208, 35, 0.35);
      padding: 16px 24px;
      border-radius: 10px;
      box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
    }
    .title-card h1 {
      font-size: 22px;
      font-weight: 800;
      letter-spacing: 0.8px;
      text-transform: uppercase;
      color: #FDD023;
    }
    .title-card p {
      font-size: 13px;
      color: #e2e8f0;
      margin-top: 4px;
    }

    .counter-card {
      background: rgba(20, 10, 40, 0.92);
      backdrop-filter: blur(10px);
      border: 1px solid rgba(253, 208, 35, 0.45);
      padding: 16px 24px;
      border-radius: 10px;
      text-align: right;
      font-variant-numeric: tabular-nums;
      box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
      min-width: 310px;
    }
    .year-display {
      font-size: 56px;
      font-weight: 800;
      color: #FDD023;
      line-height: 1;
      text-shadow: 0 2px 18px rgba(253, 208, 35, 0.45);
    }
    .pop-display {
      font-size: 20px;
      font-weight: 700;
      color: #ffffff;
      margin-top: 6px;
    }
    .growth-stats {
      margin-top: 8px;
      padding-top: 8px;
      border-top: 1px solid rgba(255, 255, 255, 0.15);
      font-size: 13px;
      line-height: 1.5;
      color: #e9d5ff;
    }
    .growth-highlight {
      color: #FDD023;
      font-weight: 700;
    }

    /* Legend Box */
    #legend {
      position: fixed;
      bottom: 124px;
      left: 36px;
      background: rgba(20, 10, 40, 0.90);
      backdrop-filter: blur(10px);
      border: 1px solid rgba(253, 208, 35, 0.35);
      padding: 12px 18px;
      border-radius: 8px;
      font-size: 13px;
      color: #f8fafc;
      z-index: 20;
      box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
      display: flex;
      flex-direction: column;
      gap: 7px;
    }
    .legend-row {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .dot-base {
      display: inline-block;
      width: 14px;
      height: 14px;
      border-radius: 50%;
      background: #9333EA;
      border: 2.5px solid #FDD023;
      box-shadow: 0 0 10px rgba(168, 85, 247, 0.95);
    }
    .dot-new {
      display: inline-block;
      width: 14px;
      height: 14px;
      border-radius: 50%;
      background: #C084FC;
      border: 2.5px solid #FFFFFF;
      box-shadow: 0 0 12px rgba(253, 208, 35, 0.95);
    }

    /* Interactive Controls */
    #controls {
      position: fixed;
      bottom: 124px;
      right: 36px;
      z-index: 20;
      display: flex;
      gap: 8px;
    }
    button {
      background: rgba(20, 10, 40, 0.90);
      backdrop-filter: blur(10px);
      color: #FDD023;
      border: 1px solid rgba(253, 208, 35, 0.45);
      padding: 9px 16px;
      border-radius: 8px;
      cursor: pointer;
      font-size: 13px;
      font-weight: 700;
      transition: all 0.15s ease;
    }
    button:hover {
      background: #7E22CE;
      color: #ffffff;
      border-color: #FDD023;
    }

    /* Bottom Timeline & Growth Bar */
    #timeline-container {
      position: fixed;
      bottom: 28px;
      left: 36px;
      right: 36px;
      background: rgba(20, 10, 40, 0.92);
      backdrop-filter: blur(10px);
      border: 1px solid rgba(253, 208, 35, 0.35);
      padding: 14px 22px;
      border-radius: 10px;
      z-index: 20;
      box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
    }
    .timeline-header {
      display: flex;
      justify-content: space-between;
      font-size: 12px;
      color: #e9d5ff;
      margin-bottom: 8px;
    }
    .timeline-track {
      width: 100%;
      height: 8px;
      background: rgba(255, 255, 255, 0.18);
      border-radius: 4px;
      cursor: pointer;
      position: relative;
      overflow: hidden;
    }
    #timeline-progress {
      height: 100%;
      width: 0%;
      background: linear-gradient(90deg, #9333EA, #FDD023);
      border-radius: 4px;
    }
    .timeline-ticks {
      display: flex;
      justify-content: space-between;
      margin-top: 8px;
      font-size: 12px;
      font-weight: 700;
      color: #f8fafc;
      font-variant-numeric: tabular-nums;
    }
  </style>
</head>
<body>
  <div id="map"></div>

  <div id="hud-top">
    <div class="title-card">
      <h1>Louisiana Population Growth</h1>
      <p>U.S. Census Bureau Historical Resident Data (1910–2020)</p>
    </div>
    <div class="counter-card">
      <div class="year-display" id="year-text">1910</div>
      <div class="pop-display" id="pop-text">1,656,388 residents</div>
      <div class="growth-stats">
        <div>Annual Change: <span class="growth-highlight" id="yoy-change">+27,476 / yr (+1.83%)</span></div>
        <div>Decade Census Change: <span class="growth-highlight" id="decade-change">+19.9% (1900–1910)</span></div>
      </div>
    </div>
  </div>

  <div id="legend">
    <div class="legend-row"><span class="dot-base"></span> 1910 Baseline (7 dots = 1.75M)</div>
    <div class="legend-row"><span class="dot-new"></span> Post-1910 Growth (+250,000 per dot)</div>
    <div style="font-size: 12px; color: #cbd5e1; margin-top: 2px;">Active Milestones: <strong style="color:#FDD023;" id="dot-count">7</strong> / 19 dots</div>
  </div>

  <div id="controls">
    <button id="play-pause-btn">Pause</button>
    <button id="replay-btn">Replay</button>
    <button id="hide-ui-btn">Clean Video Mode</button>
  </div>

  <div id="timeline-container">
    <div class="timeline-header">
      <span>Latest Milestone: <strong style="color:#FDD023;" id="latest-region">1910 Baseline Population Centers</strong></span>
      <span>Total Growth Since 1910: <strong style="color:#FDD023;" id="total-growth">+0 (+0.0%)</strong></span>
    </div>
    <div class="timeline-track" id="timeline-track">
      <div id="timeline-progress"></div>
    </div>
    <div class="timeline-ticks">
      <span>1910</span><span>1920</span><span>1930</span><span>1940</span>
      <span>1950</span><span>1960</span><span>1970</span><span>1980</span>
      <span>1990</span><span>2000</span><span>2010</span><span>2020</span>
    </div>
  </div>

  <script>
    mapboxgl.accessToken = 'pk.eyJ1Ijoic3R1ZGVudG5ld3Nsc3VzIiwiYSI6ImNtd2pzamI1MzA2djYzMHB2ajdtZjNvejAifQ.-wqukBnHQ-HwsS9zT-MH2g';

    // Official U.S. Census Bureau Decennial Resident Population & Percent Change for Louisiana
    const decennialCensus = [
      { year: 1910, pop: 1656388, decPct: 19.9, decLabel: "1900–1910" },
      { year: 1920, pop: 1798509, decPct: 8.6,  decLabel: "1910–1920" },
      { year: 1930, pop: 2101593, decPct: 16.9, decLabel: "1920–1930" },
      { year: 1940, pop: 2363880, decPct: 12.5, decLabel: "1930–1940" },
      { year: 1950, pop: 2683516, decPct: 13.5, decLabel: "1940–1950" },
      { year: 1960, pop: 3257022, decPct: 21.4, decLabel: "1950–1960" },
      { year: 1970, pop: 3641306, decPct: 11.8, decLabel: "1960–1970" },
      { year: 1980, pop: 4205900, decPct: 15.5, decLabel: "1970–1980" },
      { year: 1990, pop: 4219973, decPct: 0.3,  decLabel: "1980–1990" },
      { year: 2000, pop: 4468976, decPct: 5.9,  decLabel: "1990–2000" },
      { year: 2010, pop: 4533372, decPct: 1.4,  decLabel: "2000–2010" },
      { year: 2020, pop: 4657757, decPct: 2.7,  decLabel: "2010–2020" }
    ];

    const milestoneLabels = [
      { year: 1910, count: 7,  region: "1910 Baseline: New Orleans, Shreveport, Baton Rouge, Lafayette, Monroe, Alexandria" },
      { year: 1923, count: 8,  region: "1923 (+250k): Southwest LA (Lake Charles / Calcasieu)" },
      { year: 1931, count: 9,  region: "1931 (+250k): Bayou Region (Terrebonne / Lafourche)" },
      { year: 1941, count: 10, region: "1941 (+250k): Greater New Orleans (West Bank / Gretna)" },
      { year: 1949, count: 11, region: "1949 (+250k): Shreveport–Bossier (Bossier Parish)" },
      { year: 1954, count: 12, region: "1954 (+250k): Baton Rouge Metro (North EBR / Baker)" },
      { year: 1958, count: 13, region: "1958 (+250k): Greater New Orleans (Kenner / East Bank)" },
      { year: 1964, count: 14, region: "1964 (+250k): Acadiana Corridor (St. Landry / Iberia)" },
      { year: 1970, count: 15, region: "1970 (+250k): River Parishes (Ascension / St. Charles)" },
      { year: 1975, count: 16, region: "1975 (+250k): Florida Parishes (Tangipahoa / Hammond)" },
      { year: 1979, count: 17, region: "1979 (+250k): Northshore (St. Tammany)" },
      { year: 1997, count: 18, region: "1997 (+250k): Baton Rouge Suburbs (Livingston)" },
      { year: 2018, count: 19, region: "2018 (+250k): Acadiana Expansion (Youngsville / Broussard)" }
    ];

    const dotsGeoJSON = {
      "type": "FeatureCollection",
      "features": [
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-90.0715, 29.9511] }, "properties": { "start_year": 1910 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-90.1529, 30.0041] }, "properties": { "start_year": 1910 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-93.7502, 32.5252] }, "properties": { "start_year": 1910 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-91.1871, 30.4515] }, "properties": { "start_year": 1910 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-92.0198, 30.2241] }, "properties": { "start_year": 1910 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-92.1193, 32.5093] }, "properties": { "start_year": 1910 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-92.4451, 31.3113] }, "properties": { "start_year": 1910 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-93.2174, 30.2266] }, "properties": { "start_year": 1923 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-90.7195, 29.5958] }, "properties": { "start_year": 1931 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-90.0539, 29.9147] }, "properties": { "start_year": 1941 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-93.7321, 32.5160] }, "properties": { "start_year": 1949 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-91.1680, 30.5882] }, "properties": { "start_year": 1954 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-90.2417, 29.9941] }, "properties": { "start_year": 1958 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-91.8187, 30.0035] }, "properties": { "start_year": 1964 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-90.9225, 30.2005] }, "properties": { "start_year": 1970 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-90.4612, 30.5044] }, "properties": { "start_year": 1975 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-90.0951, 30.4755] }, "properties": { "start_year": 1979 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-90.9568, 30.4869] }, "properties": { "start_year": 1997 } },
        { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-91.9632, 30.1436] }, "properties": { "start_year": 2018 } }
      ]
    };

    const yearlyTable = {};
    for (let i = 0; i < decennialCensus.length; i++) {
      const curr = decennialCensus[i];
      if (i === 0) {
        yearlyTable[1910] = {
          pop: curr.pop,
          yoyDiff: 27476,
          yoyPct: 1.83,
          decPct: curr.decPct,
          decLabel: curr.decLabel
        };
      } else {
        const prev = decennialCensus[i - 1];
        const annualDiff = (curr.pop - prev.pop) / 10;
        for (let y = prev.year + 1; y <= curr.year; y++) {
          const steps = y - prev.year;
          const p = Math.round(prev.pop + annualDiff * steps);
          const prevP = Math.round(prev.pop + annualDiff * (steps - 1));
          const yoyDiff = p - prevP;
          const yoyPct = ((yoyDiff / prevP) * 100).toFixed(2);
          yearlyTable[y] = {
            pop: p,
            yoyDiff: yoyDiff,
            yoyPct: yoyPct,
            decPct: curr.decPct,
            decLabel: curr.decLabel
          };
        }
      }
    }

    // Use Mapbox's classic Dark v11 style (full WebGL color fidelity, zero 3D lighting darkening)
    const map = new mapboxgl.Map({
      container: 'map',
      style: 'mapbox://styles/mapbox/dark-v11',
      center: [-91.85, 31.05],
      zoom: 6.8
    });

    let currentYear = 1910;
    let isPlaying = true;
    let animTimer = null;

    window.setYear = function(year) {
      currentYear = Math.max(1910, Math.min(2020, year));
      const intYear = Math.floor(currentYear);
      const rec = yearlyTable[intYear];
      const nextRec = yearlyTable[Math.min(2020, intYear + 1)];
      const frac = currentYear - intYear;
      const smoothPop = Math.round(rec.pop + frac * (nextRec.pop - rec.pop));

      const addedSince1910 = smoothPop - 1656388;
      const pctSince1910 = ((addedSince1910 / 1656388) * 100).toFixed(1);

      document.getElementById('year-text').innerText = intYear;
      document.getElementById('pop-text').innerText = smoothPop.toLocaleString() + ' residents';
      document.getElementById('yoy-change').innerText = `+${rec.yoyDiff.toLocaleString()} / yr (+${rec.yoyPct}%)`;
      document.getElementById('decade-change').innerText = `+${rec.decPct}% (${rec.decLabel})`;
      document.getElementById('total-growth').innerText = `+${addedSince1910.toLocaleString()} (+${pctSince1910}%)`;
      document.getElementById('timeline-progress').style.width = ((currentYear - 1910) / 110 * 100) + '%';

      let activeM = milestoneLabels[0];
      for (const m of milestoneLabels) {
        if (currentYear >= m.year) activeM = m;
      }
      document.getElementById('dot-count').innerText = activeM.count;
      document.getElementById('latest-region').innerText = activeM.region;

      const yearFilter = ['<=', ['get', 'start_year'], currentYear];

      if (map.getLayer('la-dots-halo')) {
        map.setFilter('la-dots-halo', yearFilter);
      }

      if (map.getLayer('la-dots-core')) {
        map.setFilter('la-dots-core', yearFilter);
        // Smooth pop-in scale: grows from 0px to 10px over 0.6 years after each dot appears
        map.setPaintProperty('la-dots-core', 'circle-radius', [
          'interpolate', ['linear'],
          ['-', currentYear, ['get', 'start_year']],
          0, 2,
          0.35, 13,
          0.7, 9.5
        ]);
      }

      if (map.getLayer('la-dots-pulse')) {
        // Gold shockwave ring visible for the first 1.8 years after a post-1910 dot appears
        map.setFilter('la-dots-pulse', [
          'all',
          ['>', ['get', 'start_year'], 1910],
          ['<=', ['get', 'start_year'], currentYear],
          ['<', ['-', currentYear, ['get', 'start_year']], 1.8]
        ]);
        map.setPaintProperty('la-dots-pulse', 'circle-radius', [
          'interpolate', ['linear'],
          ['-', currentYear, ['get', 'start_year']],
          0, 8,
          1.8, 36
        ]);
        map.setPaintProperty('la-dots-pulse', 'circle-stroke-opacity', [
          'interpolate', ['linear'],
          ['-', currentYear, ['get', 'start_year']],
          0, 0.95,
          1.8, 0
        ]);
      }
    };

    function startPlayback() {
      if (animTimer) clearInterval(animTimer);
      isPlaying = true;
      document.getElementById('play-pause-btn').innerText = 'Pause';

      animTimer = setInterval(() => {
        if (!isPlaying) return;
        currentYear += 0.1;
        if (currentYear >= 2020) {
          window.setYear(2020);
          isPlaying = false;
          document.getElementById('play-pause-btn').innerText = 'Play';
          clearInterval(animTimer);
          return;
        }
        window.setYear(currentYear);
      }, 26);
    }

    map.on('load', () => {
      map.addSource('la-milestones', {
        type: 'geojson',
        data: dotsGeoJSON
      });

      // Layer 1: Soft Purple Ambient Glow
      map.addLayer({
        id: 'la-dots-halo',
        type: 'circle',
        source: 'la-milestones',
        filter: ['<=', ['get', 'start_year'], 1910],
        paint: {
          'circle-radius': 24,
          'circle-color': '#9333EA',
          'circle-blur': 0.9,
          'circle-opacity': 0.65
        }
      });

      // Layer 2: Expanding Gold Shockwave Ring when each new dot arrives
      map.addLayer({
        id: 'la-dots-pulse',
        type: 'circle',
        source: 'la-milestones',
        filter: ['==', ['get', 'start_year'], -1],
        paint: {
          'circle-radius': 10,
          'circle-color': 'rgba(253, 208, 35, 0)',
          'circle-stroke-width': 2.5,
          'circle-stroke-color': '#FDD023',
          'circle-stroke-opacity': 0
        }
      });

      // Layer 3: Bright Louisiana Purple Core with Gold/White Rim
      map.addLayer({
        id: 'la-dots-core',
        type: 'circle',
        source: 'la-milestones',
        filter: ['<=', ['get', 'start_year'], 1910],
        paint: {
          'circle-radius': 9.5,
          'circle-color': [
            'case',
            ['==', ['get', 'start_year'], 1910], '#9333EA',
            '#C084FC'
          ],
          'circle-stroke-width': 2.5,
          'circle-stroke-color': [
            'case',
            ['==', ['get', 'start_year'], 1910], '#FDD023',
            '#FFFFFF'
          ],
          'circle-opacity': 1
        }
      });

      window.setYear(1910);
      startPlayback();
    });

    document.getElementById('play-pause-btn').addEventListener('click', () => {
      if (currentYear >= 2020) {
        currentYear = 1910;
        startPlayback();
        return;
      }
      isPlaying = !isPlaying;
      document.getElementById('play-pause-btn').innerText = isPlaying ? 'Pause' : 'Play';
    });

    document.getElementById('replay-btn').addEventListener('click', () => {
      currentYear = 1910;
      startPlayback();
    });

    document.getElementById('hide-ui-btn').addEventListener('click', () => {
      document.getElementById('controls').style.display = 'none';
    });

    document.getElementById('timeline-track').addEventListener('click', (e) => {
      const rect = e.currentTarget.getBoundingClientRect();
      const ratio = (e.clientX - rect.left) / rect.width;
      window.setYear(1910 + ratio * 110);
    });
  </script>
</body>
</html>