colesr commited on
Commit
8e40b25
·
verified ·
1 Parent(s): 3b6e5d7

Update top-right indicator to show only variable count, remove country references

Browse files
Files changed (1) hide show
  1. static/app.js +10 -8
static/app.js CHANGED
@@ -1,5 +1,5 @@
1
  // === GLOBAL INSIGHT ENGINE v6 - DOCKER + FASTAPI ===
2
- // Updated: 2024-01-08
3
  const CONFIG = { maxCountries: 200, correlationThreshold: 0.3, outlierZScore: 2 };
4
  let dataset = [], variableDefs = [], categories = [], selectedVar = null;
5
  let corrFilter = 'all', activeCategory = null, activeTab = 'explorer', peerMode = 'global';
@@ -62,7 +62,7 @@ async function loadDefaultDataset() {
62
  unit: '', category: 'General', desc: 'World Bank indicator', icon: 'bar-chart-3', higherIsBetter: null
63
  }));
64
  DATASET_PACKS.length = 0;
65
- DATASET_PACKS.push({ name: 'World Bank Live', source: 'backend', description: 'Live World Bank indicators', variableCount: VARIABLE_DEFS.length, countryCount: DATASET.length, lastUpdated: '2024', requiresKey: false, dataset: DATASET, variables: VARIABLE_DEFS, loaded: true, file: 'backend' });
66
  CURRENT_DATASET = DATASET_PACKS[0];
67
  currentDatasetId = 'builtin:wb_live';
68
  showStatus('Live data loaded', 50);
@@ -80,7 +80,7 @@ function initDatasetSystem() {
80
  const k = Object.keys(DATASET[0]).filter(x => !['country', 'code', 'region', 'income'].includes(x));
81
  window.VARIABLE_DEFS = k.map(x => ({ key: x, name: x.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase()), unit: '', category: 'General', desc: 'Indicator', icon: 'bar-chart-3', higherIsBetter: null }));
82
  }
83
- DATASET_PACKS.push({ name: 'World Bank Core', source: 'dataset_embed.js', description: 'Economic, health, and social indicators', variableCount: VARIABLE_DEFS.length, countryCount: DATASET.length, lastUpdated: '2024', requiresKey: false, dataset: DATASET, variables: VARIABLE_DEFS, loaded: true, file: 'dataset_embed.js' });
84
  CURRENT_DATASET = DATASET_PACKS[0];
85
  }
86
  }
@@ -100,6 +100,8 @@ function switchToDataset(packName) {
100
  renderCategoryGrid(); renderVariableList(); initDecisionFramework();
101
  initBenchmark(); initSimulatorUI(); initCompareUI();
102
  lucide.createIcons(); CURRENT_DATASET = pack;
 
 
103
  return true;
104
  }
105
 
@@ -181,8 +183,8 @@ async function fetchWorldBankData() {
181
  document.getElementById('emptyState').classList.remove('hidden');
182
  document.getElementById('resultsArea').classList.add('hidden');
183
  const vs = document.getElementById('varSearch'); if (vs) vs.value = '';
184
- CURRENT_DATASET = { name: 'World Bank Custom', source: 'backend', description: `${selected.length} indicators fetched`, variableCount: vars.length, countryCount: result.data.length };
185
- showStatus(`Loaded ${result.data.length} countries, ${vars.length} vars`, 100);
186
  renderCategoryGrid(); renderVariableList(); initDecisionFramework();
187
  initBenchmark(); initSimulatorUI(); initCompareUI();
188
  lucide.createIcons();
@@ -202,8 +204,8 @@ async function fetchClimateData() {
202
  categories = [...new Set(variableDefs.map(v => v.category))];
203
  weights = {}; variableDefs.forEach(v => weights[v.key] = 1);
204
  selectedVar = null;
205
- CURRENT_DATASET = { name: 'Climate Data', source: 'Open-Meteo', description: 'Capital city climate averages', variableCount: vars.length, countryCount: result.data.length };
206
- showStatus(`Loaded climate for ${result.data.length} capitals`, 100);
207
  renderCategoryGrid(); renderVariableList(); initDecisionFramework();
208
  initBenchmark(); initSimulatorUI(); initCompareUI();
209
  lucide.createIcons();
@@ -381,7 +383,7 @@ function generateNarrative(v, corrs) {
381
  const cross = corrs.find(c => Math.abs(c.r) >= 0.5 && c.category !== v.category);
382
  const topCountry = [...dataset].sort((a, b) => (b[v.key] || 0) - (a[v.key] || 0))[0];
383
  const bottomCountry = [...dataset].sort((a, b) => (a[v.key] || 0) - (b[v.key] || 0))[0];
384
- let narrative = `${v.name} (${v.category}) varies widely across the ${dataset.length} countries studied. `;
385
  if (topCountry && topCountry[v.key] != null && bottomCountry && bottomCountry[v.key] != null) {
386
  narrative += `${topCountry.country} leads with ${topCountry[v.key].toFixed(1)} ${v.unit}, while ${bottomCountry.country} records ${bottomCountry[v.key].toFixed(1)} ${v.unit}. `;
387
  }
 
1
  // === GLOBAL INSIGHT ENGINE v6 - DOCKER + FASTAPI ===
2
+ // Updated: 2024-01-08-v5
3
  const CONFIG = { maxCountries: 200, correlationThreshold: 0.3, outlierZScore: 2 };
4
  let dataset = [], variableDefs = [], categories = [], selectedVar = null;
5
  let corrFilter = 'all', activeCategory = null, activeTab = 'explorer', peerMode = 'global';
 
62
  unit: '', category: 'General', desc: 'World Bank indicator', icon: 'bar-chart-3', higherIsBetter: null
63
  }));
64
  DATASET_PACKS.length = 0;
65
+ DATASET_PACKS.push({ name: 'World Bank Live', source: 'backend', description: 'Live World Bank indicators', variableCount: VARIABLE_DEFS.length, lastUpdated: '2024', requiresKey: false, dataset: DATASET, variables: VARIABLE_DEFS, loaded: true, file: 'backend' });
66
  CURRENT_DATASET = DATASET_PACKS[0];
67
  currentDatasetId = 'builtin:wb_live';
68
  showStatus('Live data loaded', 50);
 
80
  const k = Object.keys(DATASET[0]).filter(x => !['country', 'code', 'region', 'income'].includes(x));
81
  window.VARIABLE_DEFS = k.map(x => ({ key: x, name: x.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase()), unit: '', category: 'General', desc: 'Indicator', icon: 'bar-chart-3', higherIsBetter: null }));
82
  }
83
+ DATASET_PACKS.push({ name: 'World Bank Core', source: 'dataset_embed.js', description: 'Economic, health, and social indicators', variableCount: VARIABLE_DEFS.length, lastUpdated: '2024', requiresKey: false, dataset: DATASET, variables: VARIABLE_DEFS, loaded: true, file: 'dataset_embed.js' });
84
  CURRENT_DATASET = DATASET_PACKS[0];
85
  }
86
  }
 
100
  renderCategoryGrid(); renderVariableList(); initDecisionFramework();
101
  initBenchmark(); initSimulatorUI(); initCompareUI();
102
  lucide.createIcons(); CURRENT_DATASET = pack;
103
+ const dp2 = document.getElementById('dataPointCount');
104
+ if (dp2) dp2.innerHTML = `<span class="w-2 h-2 rounded-full bg-emerald-400 pulse-dot"></span><span>${variableDefs.length} variables</span>`;
105
  return true;
106
  }
107
 
 
183
  document.getElementById('emptyState').classList.remove('hidden');
184
  document.getElementById('resultsArea').classList.add('hidden');
185
  const vs = document.getElementById('varSearch'); if (vs) vs.value = '';
186
+ CURRENT_DATASET = { name: 'World Bank Custom', source: 'backend', description: `${selected.length} indicators fetched`, variableCount: vars.length };
187
+ showStatus(`Loaded ${vars.length} variables`, 100);
188
  renderCategoryGrid(); renderVariableList(); initDecisionFramework();
189
  initBenchmark(); initSimulatorUI(); initCompareUI();
190
  lucide.createIcons();
 
204
  categories = [...new Set(variableDefs.map(v => v.category))];
205
  weights = {}; variableDefs.forEach(v => weights[v.key] = 1);
206
  selectedVar = null;
207
+ CURRENT_DATASET = { name: 'Climate Data', source: 'Open-Meteo', description: 'Capital city climate averages', variableCount: vars.length };
208
+ showStatus(`Loaded ${vars.length} variables`, 100);
209
  renderCategoryGrid(); renderVariableList(); initDecisionFramework();
210
  initBenchmark(); initSimulatorUI(); initCompareUI();
211
  lucide.createIcons();
 
383
  const cross = corrs.find(c => Math.abs(c.r) >= 0.5 && c.category !== v.category);
384
  const topCountry = [...dataset].sort((a, b) => (b[v.key] || 0) - (a[v.key] || 0))[0];
385
  const bottomCountry = [...dataset].sort((a, b) => (a[v.key] || 0) - (b[v.key] || 0))[0];
386
+ let narrative = `${v.name} (${v.category}) varies widely. `;
387
  if (topCountry && topCountry[v.key] != null && bottomCountry && bottomCountry[v.key] != null) {
388
  narrative += `${topCountry.country} leads with ${topCountry[v.key].toFixed(1)} ${v.unit}, while ${bottomCountry.country} records ${bottomCountry[v.key].toFixed(1)} ${v.unit}. `;
389
  }