Issue: COVID-19, Influenza, and RSV cards stuck on "Loading..." with - values
Look for this log on page load:
[RESPIRATORY CHART] Initializing disease cards...
Look for this log:
[DISEASE CARDS] ========== UPDATING CARDS (BigQuery) ==========
[DISEASE CARDS] Days: 7
[DISEASE CARDS] State: California Location text: California
Look for:
[DISEASE CARDS] Fetching BigQuery data: /api/infectious-disease-dashboard?state=California&days=7
[DISEASE CARDS] Response status: 200
[DISEASE CARDS] BigQuery Result status: success
Look for any red error messages containing:
[DISEASE CARDS]updateDiseaseCardsinfectious-disease-dashboard
Symptom: No console logs at all
Cause: Script not loaded or JavaScript error earlier in page
Solution: Check for any red errors in console before the page finishes loading
Symptom: Logs show API called but status is not 'success'
Cause: BigQuery tables empty or not accessible
Solution: This is expected for development - tables need to be populated
Symptom: Logs show State: Location text: National
Cause: currentState variable not set when cards initialize
Solution: Need to ensure currentState = 'California' before cards load
Symptom: Cards load before state is set
Cause: updateDiseaseCards(7) runs before currentState is initialized
Solution: Call updateDiseaseCards after state is set
Open browser console and manually run:
// Check if function exists
console.log('updateDiseaseCards:', typeof updateDiseaseCards);
// Check if currentState is set
console.log('currentState:', window.currentState);
// Manually trigger update
if (typeof updateDiseaseCards === 'function') {
updateDiseaseCards(7);
}This will tell us:
- ✅ If the function is available
- ✅ If the state variable is accessible
- ✅ What happens when we manually call it
If everything is working, you should see:
[RESPIRATORY CHART] Initializing disease cards...
[DISEASE CARDS] ========== UPDATING CARDS (BigQuery) ==========
[DISEASE CARDS] Days: 7
[DISEASE CARDS] State: California Location text: California
[DISEASE CARDS] Updated location indicator
[DISEASE CARDS] Fetching BigQuery data: /api/infectious-disease-dashboard?state=California&days=7
[DISEASE CARDS] Response status: 200
[DISEASE CARDS] BigQuery Result status: success
[DISEASE CARDS] ✅ BigQuery data received
[DISEASE CARDS] RSV avg positivity from BigQuery: 12.5
[DISEASE CARDS] COVID avg positivity from BigQuery: 8.3
[DISEASE CARDS] Flu avg positivity from BigQuery: 5.7
Based on the symptoms, the most likely issue is:
Why:
updateDiseaseCards(7)is called in asetTimeout(..., 500)- But
currentStatemight not be set yet ininitializeApp() - The function looks for
currentStatevariable to determine the state
How to verify: In the console logs, look for:
[DISEASE CARDS] State: Location text: National
If "State:" is empty, that's the problem!
If currentState is undefined, we need to ensure the disease cards load AFTER the state is set in app.js.
Currently:
// app.js - initializeApp()
currentState = 'California'; // Line 523
// ... lots of other code ...
// respiratory-chart.js - runs 500ms after DOM loads
updateDiseaseCards(7); // This might run before currentState is set!Fix: Call updateDiseaseCards after we're sure currentState is set.