784 lines
34 KiB
HTML
784 lines
34 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Polio Eradication Progress: Global Vaccination Time Series 2000-2023</title>
|
|
<link href='https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl.css' rel='stylesheet' />
|
|
<script src='https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl.js'></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
background: #0a0e27;
|
|
color: #e5e7eb;
|
|
overflow: hidden;
|
|
}
|
|
|
|
#map {
|
|
position: absolute;
|
|
top: 0;
|
|
bottom: 0;
|
|
width: 100%;
|
|
}
|
|
|
|
.info-overlay {
|
|
position: absolute;
|
|
top: 20px;
|
|
left: 20px;
|
|
background: rgba(15, 23, 42, 0.95);
|
|
padding: 24px;
|
|
border-radius: 12px;
|
|
max-width: 400px;
|
|
backdrop-filter: blur(10px);
|
|
border: 1px solid rgba(139, 92, 246, 0.3);
|
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
|
}
|
|
|
|
.info-overlay h1 {
|
|
font-size: 24px;
|
|
font-weight: 700;
|
|
margin-bottom: 8px;
|
|
background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
background-clip: text;
|
|
}
|
|
|
|
.info-overlay p {
|
|
font-size: 14px;
|
|
color: #94a3b8;
|
|
margin-bottom: 16px;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.stats-grid {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 12px;
|
|
margin-top: 16px;
|
|
}
|
|
|
|
.stat-card {
|
|
background: rgba(139, 92, 246, 0.1);
|
|
padding: 12px;
|
|
border-radius: 8px;
|
|
border: 1px solid rgba(139, 92, 246, 0.2);
|
|
}
|
|
|
|
.stat-label {
|
|
font-size: 11px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
color: #94a3b8;
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 20px;
|
|
font-weight: 700;
|
|
color: #8b5cf6;
|
|
}
|
|
|
|
.timeline-control {
|
|
position: absolute;
|
|
bottom: 40px;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
background: rgba(15, 23, 42, 0.95);
|
|
padding: 24px 32px;
|
|
border-radius: 16px;
|
|
backdrop-filter: blur(10px);
|
|
border: 1px solid rgba(139, 92, 246, 0.3);
|
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
|
min-width: 600px;
|
|
}
|
|
|
|
.timeline-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.year-display {
|
|
font-size: 32px;
|
|
font-weight: 700;
|
|
color: #8b5cf6;
|
|
text-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
|
|
}
|
|
|
|
.play-pause-btn {
|
|
background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
|
|
border: none;
|
|
color: white;
|
|
padding: 12px 24px;
|
|
border-radius: 8px;
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
|
|
}
|
|
|
|
.play-pause-btn:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
|
|
}
|
|
|
|
.play-pause-btn:active {
|
|
transform: translateY(0);
|
|
}
|
|
|
|
.slider-container {
|
|
position: relative;
|
|
margin-top: 8px;
|
|
}
|
|
|
|
.timeline-slider {
|
|
width: 100%;
|
|
height: 8px;
|
|
border-radius: 4px;
|
|
background: rgba(139, 92, 246, 0.2);
|
|
outline: none;
|
|
-webkit-appearance: none;
|
|
appearance: none;
|
|
}
|
|
|
|
.timeline-slider::-webkit-slider-thumb {
|
|
-webkit-appearance: none;
|
|
appearance: none;
|
|
width: 20px;
|
|
height: 20px;
|
|
border-radius: 50%;
|
|
background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
|
|
cursor: pointer;
|
|
box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.3);
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.timeline-slider::-webkit-slider-thumb:hover {
|
|
box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.4);
|
|
}
|
|
|
|
.timeline-slider::-moz-range-thumb {
|
|
width: 20px;
|
|
height: 20px;
|
|
border-radius: 50%;
|
|
background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
|
|
cursor: pointer;
|
|
border: none;
|
|
box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.3);
|
|
}
|
|
|
|
.year-labels {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
margin-top: 8px;
|
|
font-size: 11px;
|
|
color: #64748b;
|
|
}
|
|
|
|
.mapboxgl-popup-content {
|
|
background: rgba(15, 23, 42, 0.98);
|
|
border-radius: 12px;
|
|
padding: 0;
|
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
|
|
border: 1px solid rgba(139, 92, 246, 0.3);
|
|
min-width: 450px;
|
|
}
|
|
|
|
.mapboxgl-popup-close-button {
|
|
color: #e5e7eb;
|
|
font-size: 20px;
|
|
padding: 8px;
|
|
right: 8px;
|
|
top: 8px;
|
|
}
|
|
|
|
.mapboxgl-popup-close-button:hover {
|
|
background: rgba(139, 92, 246, 0.2);
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.chart-popup {
|
|
padding: 20px;
|
|
}
|
|
|
|
.chart-popup h3 {
|
|
font-size: 18px;
|
|
font-weight: 700;
|
|
color: #8b5cf6;
|
|
margin-bottom: 16px;
|
|
text-align: center;
|
|
}
|
|
|
|
.chart-container {
|
|
position: relative;
|
|
height: 250px;
|
|
margin-top: 12px;
|
|
}
|
|
|
|
.legend {
|
|
position: absolute;
|
|
bottom: 120px;
|
|
right: 20px;
|
|
background: rgba(15, 23, 42, 0.95);
|
|
padding: 16px;
|
|
border-radius: 8px;
|
|
border: 1px solid rgba(139, 92, 246, 0.3);
|
|
backdrop-filter: blur(10px);
|
|
}
|
|
|
|
.legend-title {
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
color: #e5e7eb;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.legend-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
margin-bottom: 6px;
|
|
font-size: 11px;
|
|
}
|
|
|
|
.legend-color {
|
|
width: 16px;
|
|
height: 3px;
|
|
border-radius: 2px;
|
|
}
|
|
|
|
.loading {
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
font-size: 18px;
|
|
color: #8b5cf6;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="map"></div>
|
|
<div class="loading">Initializing globe and loading polio eradication data...</div>
|
|
|
|
<div class="info-overlay">
|
|
<h1>Polio Eradication Progress</h1>
|
|
<p>Global vaccination coverage and case reduction from 2000 to 2023. Hover over countries to see 24-year trends with Chart.js visualizations.</p>
|
|
<div class="stats-grid">
|
|
<div class="stat-card">
|
|
<div class="stat-label">Global Coverage 2023</div>
|
|
<div class="stat-value">84%</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-label">Wild Cases 2023</div>
|
|
<div class="stat-value"><50</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-label">Endemic Countries</div>
|
|
<div class="stat-value">2</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-label">Reduction Since 1988</div>
|
|
<div class="stat-value">99.9%</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="timeline-control">
|
|
<div class="timeline-header">
|
|
<div class="year-display" id="year-display">2000</div>
|
|
<button class="play-pause-btn" id="play-pause">▶️ Play</button>
|
|
</div>
|
|
<div class="slider-container">
|
|
<input type="range" min="0" max="23" value="0" class="timeline-slider" id="timeline-slider">
|
|
<div class="year-labels">
|
|
<span>2000</span>
|
|
<span>2006</span>
|
|
<span>2012</span>
|
|
<span>2018</span>
|
|
<span>2023</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="legend">
|
|
<div class="legend-title">Coverage Level</div>
|
|
<div class="legend-item">
|
|
<div class="legend-color" style="background: #10b981;"></div>
|
|
<span>High (≥95%)</span>
|
|
</div>
|
|
<div class="legend-item">
|
|
<div class="legend-color" style="background: #f59e0b;"></div>
|
|
<span>Medium (80-95%)</span>
|
|
</div>
|
|
<div class="legend-item">
|
|
<div class="legend-color" style="background: #ef4444;"></div>
|
|
<span>Low (<80%)</span>
|
|
</div>
|
|
</div>
|
|
|
|
<script type="module">
|
|
// Import shared Mapbox configuration
|
|
import { MAPBOX_CONFIG } from '../../mapbox_test/shared/mapbox-config.js';
|
|
|
|
mapboxgl.accessToken = MAPBOX_CONFIG.accessToken;
|
|
|
|
// Generate realistic polio vaccination data for 60+ countries
|
|
function generatePolioData() {
|
|
const countries = [
|
|
// Endemic/High-burden countries (historically challenging)
|
|
{ name: 'Afghanistan', coords: [67.7099, 33.9391], baselineCoverage: 45, endCoverage: 68, baselineCases: 350, endemic: true },
|
|
{ name: 'Pakistan', coords: [69.3451, 30.3753], baselineCoverage: 52, endCoverage: 72, baselineCases: 420, endemic: true },
|
|
{ name: 'Nigeria', coords: [8.6753, 9.0820], baselineCoverage: 38, endCoverage: 76, baselineCases: 280, endemic: false },
|
|
{ name: 'India', coords: [78.9629, 20.5937], baselineCoverage: 62, endCoverage: 95, baselineCases: 265, endemic: false },
|
|
{ name: 'Somalia', coords: [46.1996, 5.1521], baselineCoverage: 25, endCoverage: 55, baselineCases: 180, endemic: false },
|
|
{ name: 'Yemen', coords: [48.5164, 15.5527], baselineCoverage: 48, endCoverage: 65, baselineCases: 95, endemic: false },
|
|
{ name: 'Syria', coords: [38.9968, 34.8021], baselineCoverage: 72, endCoverage: 58, baselineCases: 45, endemic: false },
|
|
{ name: 'Iraq', coords: [43.6793, 33.2232], baselineCoverage: 65, endCoverage: 82, baselineCases: 38, endemic: false },
|
|
{ name: 'Chad', coords: [18.7322, 15.4542], baselineCoverage: 35, endCoverage: 62, baselineCases: 75, endemic: false },
|
|
{ name: 'Niger', coords: [8.0817, 17.6078], baselineCoverage: 42, endCoverage: 78, baselineCases: 68, endemic: false },
|
|
|
|
// Sub-Saharan Africa (improving coverage)
|
|
{ name: 'Ethiopia', coords: [40.4897, 9.1450], baselineCoverage: 55, endCoverage: 85, baselineCases: 52, endemic: false },
|
|
{ name: 'Kenya', coords: [37.9062, -0.0236], baselineCoverage: 68, endCoverage: 92, baselineCases: 28, endemic: false },
|
|
{ name: 'Tanzania', coords: [34.8888, -6.3690], baselineCoverage: 72, endCoverage: 94, baselineCases: 18, endemic: false },
|
|
{ name: 'Uganda', coords: [32.2903, 1.3733], baselineCoverage: 65, endCoverage: 90, baselineCases: 22, endemic: false },
|
|
{ name: 'DRC', coords: [21.7587, -4.0383], baselineCoverage: 42, endCoverage: 71, baselineCases: 85, endemic: false },
|
|
{ name: 'Angola', coords: [17.8739, -11.2027], baselineCoverage: 48, endCoverage: 78, baselineCases: 42, endemic: false },
|
|
{ name: 'Mozambique', coords: [35.5296, -18.6657], baselineCoverage: 58, endCoverage: 88, baselineCases: 32, endemic: false },
|
|
{ name: 'Madagascar', coords: [46.8691, -18.7669], baselineCoverage: 62, endCoverage: 85, baselineCases: 25, endemic: false },
|
|
{ name: 'Cameroon', coords: [12.3547, 7.3697], baselineCoverage: 52, endCoverage: 82, baselineCases: 38, endemic: false },
|
|
{ name: 'Senegal', coords: [-14.4524, 14.4974], baselineCoverage: 68, endCoverage: 93, baselineCases: 15, endemic: false },
|
|
{ name: 'Ghana', coords: [-1.0232, 7.9465], baselineCoverage: 75, endCoverage: 95, baselineCases: 8, endemic: false },
|
|
{ name: 'Mali', coords: [-3.9962, 17.5707], baselineCoverage: 45, endCoverage: 76, baselineCases: 48, endemic: false },
|
|
{ name: 'Burkina Faso', coords: [-1.5616, 12.2383], baselineCoverage: 52, endCoverage: 84, baselineCases: 35, endemic: false },
|
|
{ name: 'Rwanda', coords: [29.8739, -1.9403], baselineCoverage: 82, endCoverage: 98, baselineCases: 5, endemic: false },
|
|
|
|
// South Asia (strong progress)
|
|
{ name: 'Bangladesh', coords: [90.3563, 23.6850], baselineCoverage: 68, endCoverage: 96, baselineCases: 42, endemic: false },
|
|
{ name: 'Nepal', coords: [84.1240, 28.3949], baselineCoverage: 72, endCoverage: 94, baselineCases: 18, endemic: false },
|
|
{ name: 'Myanmar', coords: [95.9560, 21.9162], baselineCoverage: 62, endCoverage: 88, baselineCases: 28, endemic: false },
|
|
{ name: 'Sri Lanka', coords: [80.7718, 7.8731], baselineCoverage: 92, endCoverage: 99, baselineCases: 2, endemic: false },
|
|
|
|
// Southeast Asia (high achievers)
|
|
{ name: 'Indonesia', coords: [113.9213, -0.7893], baselineCoverage: 78, endCoverage: 96, baselineCases: 12, endemic: false },
|
|
{ name: 'Philippines', coords: [121.7740, 12.8797], baselineCoverage: 75, endCoverage: 93, baselineCases: 15, endemic: false },
|
|
{ name: 'Vietnam', coords: [108.2772, 14.0583], baselineCoverage: 88, endCoverage: 97, baselineCases: 5, endemic: false },
|
|
{ name: 'Thailand', coords: [100.9925, 15.8700], baselineCoverage: 92, endCoverage: 99, baselineCases: 1, endemic: false },
|
|
{ name: 'Cambodia', coords: [104.9910, 12.5657], baselineCoverage: 68, endCoverage: 92, baselineCases: 18, endemic: false },
|
|
{ name: 'Laos', coords: [102.4955, 19.8563], baselineCoverage: 62, endCoverage: 88, baselineCases: 22, endemic: false },
|
|
|
|
// Latin America (excellence)
|
|
{ name: 'Brazil', coords: [-51.9253, -14.2350], baselineCoverage: 92, endCoverage: 97, baselineCases: 3, endemic: false },
|
|
{ name: 'Mexico', coords: [-102.5528, 23.6345], baselineCoverage: 88, endCoverage: 96, baselineCases: 5, endemic: false },
|
|
{ name: 'Colombia', coords: [-74.2973, 4.5709], baselineCoverage: 85, endCoverage: 94, baselineCases: 8, endemic: false },
|
|
{ name: 'Peru', coords: [-75.0152, -9.1900], baselineCoverage: 82, endCoverage: 93, baselineCases: 12, endemic: false },
|
|
{ name: 'Venezuela', coords: [-66.5897, 6.4238], baselineCoverage: 78, endCoverage: 85, baselineCases: 18, endemic: false },
|
|
{ name: 'Bolivia', coords: [-63.5887, -16.2902], baselineCoverage: 72, endCoverage: 88, baselineCases: 22, endemic: false },
|
|
{ name: 'Haiti', coords: [-72.2852, 18.9712], baselineCoverage: 42, endCoverage: 68, baselineCases: 55, endemic: false },
|
|
|
|
// Middle East & North Africa
|
|
{ name: 'Egypt', coords: [30.8025, 26.8206], baselineCoverage: 82, endCoverage: 96, baselineCases: 15, endemic: false },
|
|
{ name: 'Morocco', coords: [-7.0926, 31.7917], baselineCoverage: 88, endCoverage: 97, baselineCases: 5, endemic: false },
|
|
{ name: 'Algeria', coords: [1.6596, 28.0339], baselineCoverage: 85, endCoverage: 95, baselineCases: 8, endemic: false },
|
|
{ name: 'Sudan', coords: [30.2176, 12.8628], baselineCoverage: 52, endCoverage: 78, baselineCases: 48, endemic: false },
|
|
{ name: 'South Sudan', coords: [31.3070, 6.8770], baselineCoverage: 28, endCoverage: 52, baselineCases: 88, endemic: false },
|
|
|
|
// Developed regions (near-perfect)
|
|
{ name: 'United States', coords: [-95.7129, 37.0902], baselineCoverage: 95, endCoverage: 93, baselineCases: 0, endemic: false },
|
|
{ name: 'United Kingdom', coords: [-3.4360, 55.3781], baselineCoverage: 96, endCoverage: 94, baselineCases: 0, endemic: false },
|
|
{ name: 'France', coords: [2.2137, 46.2276], baselineCoverage: 97, endCoverage: 95, baselineCases: 0, endemic: false },
|
|
{ name: 'Germany', coords: [10.4515, 51.1657], baselineCoverage: 97, endCoverage: 95, baselineCases: 0, endemic: false },
|
|
{ name: 'Italy', coords: [12.5674, 41.8719], baselineCoverage: 96, endCoverage: 94, baselineCases: 0, endemic: false },
|
|
{ name: 'Spain', coords: [-3.7492, 40.4637], baselineCoverage: 97, endCoverage: 95, baselineCases: 0, endemic: false },
|
|
{ name: 'Canada', coords: [-106.3468, 56.1304], baselineCoverage: 96, endCoverage: 94, baselineCases: 0, endemic: false },
|
|
{ name: 'Australia', coords: [133.7751, -25.2744], baselineCoverage: 97, endCoverage: 95, baselineCases: 0, endemic: false },
|
|
{ name: 'Japan', coords: [138.2529, 36.2048], baselineCoverage: 97, endCoverage: 96, baselineCases: 0, endemic: false },
|
|
{ name: 'South Korea', coords: [127.7669, 35.9078], baselineCoverage: 98, endCoverage: 97, baselineCases: 0, endemic: false },
|
|
|
|
// Additional countries for diversity
|
|
{ name: 'China', coords: [104.1954, 35.8617], baselineCoverage: 92, endCoverage: 99, baselineCases: 5, endemic: false },
|
|
{ name: 'Russia', coords: [105.3188, 61.5240], baselineCoverage: 88, endCoverage: 97, baselineCases: 8, endemic: false },
|
|
{ name: 'Turkey', coords: [35.2433, 38.9637], baselineCoverage: 82, endCoverage: 94, baselineCases: 12, endemic: false },
|
|
{ name: 'Iran', coords: [53.6880, 32.4279], baselineCoverage: 85, endCoverage: 95, baselineCases: 10, endemic: false },
|
|
{ name: 'Saudi Arabia', coords: [45.0792, 23.8859], baselineCoverage: 90, endCoverage: 98, baselineCases: 3, endemic: false },
|
|
{ name: 'South Africa', coords: [22.9375, -30.5595], baselineCoverage: 78, endCoverage: 91, baselineCases: 15, endemic: false },
|
|
{ name: 'Argentina', coords: [-63.6167, -38.4161], baselineCoverage: 90, endCoverage: 95, baselineCases: 5, endemic: false },
|
|
{ name: 'Chile', coords: [-71.5430, -35.6751], baselineCoverage: 93, endCoverage: 97, baselineCases: 2, endemic: false },
|
|
];
|
|
|
|
const features = countries.map(country => {
|
|
const years = [];
|
|
const coverage = [];
|
|
const cases = [];
|
|
|
|
for (let year = 2000; year <= 2023; year++) {
|
|
years.push(year);
|
|
|
|
// Calculate coverage progression
|
|
const progress = (year - 2000) / 23;
|
|
let yearCoverage;
|
|
|
|
if (country.endemic) {
|
|
// Endemic countries: slow, irregular progress
|
|
yearCoverage = country.baselineCoverage +
|
|
(country.endCoverage - country.baselineCoverage) * progress +
|
|
Math.sin(progress * Math.PI * 3) * 5; // Fluctuations
|
|
} else if (country.baselineCoverage < 60) {
|
|
// Low baseline: rapid initial improvement, then plateau
|
|
yearCoverage = country.baselineCoverage +
|
|
(country.endCoverage - country.baselineCoverage) *
|
|
(1 - Math.exp(-progress * 3));
|
|
} else if (country.baselineCoverage >= 95) {
|
|
// High achievers: slight decline due to vaccine hesitancy
|
|
yearCoverage = country.baselineCoverage -
|
|
(country.baselineCoverage - country.endCoverage) *
|
|
(1 - Math.exp(-progress * 2));
|
|
} else {
|
|
// Middle range: steady improvement
|
|
yearCoverage = country.baselineCoverage +
|
|
(country.endCoverage - country.baselineCoverage) * progress;
|
|
}
|
|
|
|
coverage.push(Math.max(0, Math.min(100, yearCoverage)).toFixed(1));
|
|
|
|
// Calculate cases (inverse relationship with coverage)
|
|
let yearCases;
|
|
if (country.endemic) {
|
|
// Endemic: persistent cases with slow reduction
|
|
yearCases = country.baselineCases * (1 - progress * 0.6) *
|
|
(1 + Math.sin(progress * Math.PI * 4) * 0.3);
|
|
} else if (country.baselineCases === 0) {
|
|
// Polio-free regions
|
|
yearCases = 0;
|
|
} else {
|
|
// Rapid case reduction as coverage improves
|
|
const coverageImprovement = (yearCoverage - country.baselineCoverage) /
|
|
(country.endCoverage - country.baselineCoverage);
|
|
yearCases = country.baselineCases * Math.exp(-coverageImprovement * 5);
|
|
}
|
|
|
|
cases.push(Math.max(0, yearCases).toFixed(0));
|
|
}
|
|
|
|
return {
|
|
type: 'Feature',
|
|
geometry: {
|
|
type: 'Point',
|
|
coordinates: country.coords
|
|
},
|
|
properties: {
|
|
name: country.name,
|
|
endemic: country.endemic,
|
|
// Store arrays as JSON strings for GeoJSON compatibility
|
|
years_array: JSON.stringify(years),
|
|
coverage_array: JSON.stringify(coverage),
|
|
cases_array: JSON.stringify(cases),
|
|
// Current year data (will be updated)
|
|
year: 2000,
|
|
coverage: coverage[0],
|
|
cases: cases[0]
|
|
}
|
|
};
|
|
});
|
|
|
|
return {
|
|
type: 'FeatureCollection',
|
|
features: features
|
|
};
|
|
}
|
|
|
|
const polioData = generatePolioData();
|
|
|
|
const map = new mapboxgl.Map({
|
|
container: 'map',
|
|
style: 'mapbox://styles/mapbox/dark-v11',
|
|
projection: 'globe',
|
|
center: [20, 20],
|
|
zoom: 1.8,
|
|
pitch: 0
|
|
});
|
|
|
|
map.on('style.load', () => {
|
|
map.setFog({
|
|
color: 'rgb(10, 14, 39)',
|
|
'high-color': 'rgb(139, 92, 246)',
|
|
'horizon-blend': 0.05,
|
|
'space-color': 'rgb(6, 8, 20)',
|
|
'star-intensity': 0.8
|
|
});
|
|
|
|
// Add data source
|
|
map.addSource('polio-data', {
|
|
type: 'geojson',
|
|
data: polioData
|
|
});
|
|
|
|
// Add circle layer with coverage-based coloring
|
|
map.addLayer({
|
|
id: 'polio-layer',
|
|
type: 'circle',
|
|
source: 'polio-data',
|
|
paint: {
|
|
'circle-radius': [
|
|
'interpolate', ['linear'], ['zoom'],
|
|
1, 4,
|
|
5, 12
|
|
],
|
|
'circle-color': [
|
|
'interpolate', ['linear'], ['get', 'coverage'],
|
|
0, '#ef4444', // Red: Low coverage
|
|
80, '#f59e0b', // Orange: Medium
|
|
95, '#10b981' // Green: High
|
|
],
|
|
'circle-opacity': 0.85,
|
|
'circle-stroke-width': 2,
|
|
'circle-stroke-color': '#ffffff',
|
|
'circle-stroke-opacity': 0.3
|
|
}
|
|
});
|
|
|
|
// Remove loading message
|
|
document.querySelector('.loading').remove();
|
|
|
|
// Chart counter for unique canvas IDs (Chart.js requirement)
|
|
let chartCounter = 0;
|
|
let currentPopup = null;
|
|
|
|
// Hover interaction with Chart.js integration
|
|
map.on('mouseenter', 'polio-layer', (e) => {
|
|
map.getCanvas().style.cursor = 'pointer';
|
|
|
|
const feature = e.features[0];
|
|
const properties = feature.properties;
|
|
|
|
// Parse time series data
|
|
const years = JSON.parse(properties.years_array);
|
|
const coverage = JSON.parse(properties.coverage_array).map(v => parseFloat(v));
|
|
const cases = JSON.parse(properties.cases_array).map(v => parseInt(v));
|
|
|
|
// Close existing popup
|
|
if (currentPopup) {
|
|
currentPopup.remove();
|
|
}
|
|
|
|
// Unique canvas ID for this chart
|
|
const canvasId = `chart-${chartCounter++}`;
|
|
|
|
// Create popup with canvas element
|
|
currentPopup = new mapboxgl.Popup({
|
|
offset: 15,
|
|
closeButton: true,
|
|
closeOnClick: false
|
|
})
|
|
.setLngLat(feature.geometry.coordinates)
|
|
.setHTML(`
|
|
<div class="chart-popup">
|
|
<h3>${properties.name}</h3>
|
|
<div class="chart-container">
|
|
<canvas id="${canvasId}" width="400" height="250"></canvas>
|
|
</div>
|
|
</div>
|
|
`)
|
|
.addTo(map);
|
|
|
|
// Initialize Chart.js AFTER popup is added to DOM
|
|
// Configuration from Chart.js line chart documentation
|
|
const ctx = document.getElementById(canvasId).getContext('2d');
|
|
new Chart(ctx, {
|
|
type: 'line',
|
|
data: {
|
|
labels: years,
|
|
datasets: [
|
|
{
|
|
label: 'Vaccination Coverage (%)',
|
|
data: coverage,
|
|
borderColor: 'rgb(75, 192, 192)',
|
|
backgroundColor: 'rgba(75, 192, 192, 0.1)',
|
|
tension: 0.3, // Smooth curves from Chart.js docs
|
|
fill: true, // Fill area under line
|
|
borderWidth: 2,
|
|
pointRadius: 2,
|
|
pointHoverRadius: 5
|
|
},
|
|
{
|
|
label: 'Wild Polio Cases',
|
|
data: cases,
|
|
borderColor: 'rgb(239, 68, 68)',
|
|
backgroundColor: 'rgba(239, 68, 68, 0.1)',
|
|
tension: 0.3,
|
|
fill: true,
|
|
borderWidth: 2,
|
|
pointRadius: 2,
|
|
pointHoverRadius: 5,
|
|
yAxisID: 'y'
|
|
}
|
|
]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
interaction: {
|
|
mode: 'index',
|
|
intersect: false
|
|
},
|
|
plugins: {
|
|
title: {
|
|
display: true,
|
|
text: 'Polio Vaccination Progress (2000-2023)',
|
|
color: '#e5e7eb',
|
|
font: {
|
|
size: 14,
|
|
weight: 'bold'
|
|
}
|
|
},
|
|
legend: {
|
|
labels: {
|
|
color: '#e5e7eb',
|
|
font: {
|
|
size: 11
|
|
}
|
|
}
|
|
},
|
|
tooltip: {
|
|
backgroundColor: 'rgba(15, 23, 42, 0.95)',
|
|
titleColor: '#8b5cf6',
|
|
bodyColor: '#e5e7eb',
|
|
borderColor: 'rgba(139, 92, 246, 0.3)',
|
|
borderWidth: 1
|
|
}
|
|
},
|
|
scales: {
|
|
x: {
|
|
grid: {
|
|
color: 'rgba(139, 92, 246, 0.1)'
|
|
},
|
|
ticks: {
|
|
color: '#94a3b8',
|
|
maxRotation: 45,
|
|
minRotation: 45,
|
|
font: {
|
|
size: 9
|
|
}
|
|
}
|
|
},
|
|
y: {
|
|
type: 'linear',
|
|
display: true,
|
|
position: 'left',
|
|
title: {
|
|
display: true,
|
|
text: 'Coverage % / Cases',
|
|
color: '#e5e7eb'
|
|
},
|
|
grid: {
|
|
color: 'rgba(139, 92, 246, 0.1)'
|
|
},
|
|
ticks: {
|
|
color: '#94a3b8',
|
|
font: {
|
|
size: 10
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
map.on('mouseleave', 'polio-layer', () => {
|
|
map.getCanvas().style.cursor = '';
|
|
if (currentPopup) {
|
|
currentPopup.remove();
|
|
currentPopup = null;
|
|
}
|
|
});
|
|
|
|
// Timeline controls with auto-play functionality
|
|
const slider = document.getElementById('timeline-slider');
|
|
const yearDisplay = document.getElementById('year-display');
|
|
const playPauseBtn = document.getElementById('play-pause');
|
|
|
|
let isPlaying = false;
|
|
let playInterval;
|
|
|
|
function updateMapForYear(yearIndex) {
|
|
const year = 2000 + yearIndex;
|
|
yearDisplay.textContent = year;
|
|
|
|
// Update each feature's current year data
|
|
const updatedData = {
|
|
...polioData,
|
|
features: polioData.features.map(feature => {
|
|
const coverage = JSON.parse(feature.properties.coverage_array);
|
|
const cases = JSON.parse(feature.properties.cases_array);
|
|
|
|
return {
|
|
...feature,
|
|
properties: {
|
|
...feature.properties,
|
|
year: year,
|
|
coverage: parseFloat(coverage[yearIndex]),
|
|
cases: parseInt(cases[yearIndex])
|
|
}
|
|
};
|
|
})
|
|
};
|
|
|
|
map.getSource('polio-data').setData(updatedData);
|
|
}
|
|
|
|
slider.addEventListener('input', (e) => {
|
|
updateMapForYear(parseInt(e.target.value));
|
|
});
|
|
|
|
// Auto-play implementation
|
|
playPauseBtn.addEventListener('click', () => {
|
|
isPlaying = !isPlaying;
|
|
|
|
if (isPlaying) {
|
|
playInterval = setInterval(() => {
|
|
let current = parseInt(slider.value);
|
|
current = (current + 1) % 24; // Loop back to 2000 after 2023
|
|
slider.value = current;
|
|
updateMapForYear(current);
|
|
}, 1000); // 1 second per year
|
|
|
|
playPauseBtn.textContent = '⏸️ Pause';
|
|
} else {
|
|
clearInterval(playInterval);
|
|
playPauseBtn.textContent = '▶️ Play';
|
|
}
|
|
});
|
|
|
|
// Smooth globe rotation
|
|
let userInteracting = false;
|
|
map.on('mousedown', () => { userInteracting = true; });
|
|
map.on('mouseup', () => { userInteracting = false; });
|
|
|
|
function rotateGlobe() {
|
|
if (!userInteracting && !isPlaying) {
|
|
map.easeTo({
|
|
center: [map.getCenter().lng + 0.05, map.getCenter().lat],
|
|
duration: 1000,
|
|
easing: t => t
|
|
});
|
|
}
|
|
requestAnimationFrame(rotateGlobe);
|
|
}
|
|
rotateGlobe();
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|