Skip to content

Conversation

@mohammed-saalim
Copy link
Contributor

Fixes bubble chart to work with v2 state models and enables dynamic state switching with D3 animations.

Implements Loren's Requested Updates:

  1. Direct Data Pull from GitHub (no local JSON files in repo)
  2. Red Bubble Highlighting for Each State's Top Industries

Problems Fixed:

  1. Hardcoded CSV Loading
  • Chart was hardcoded to load from CSV and only supported US/GA data
  • Implemented dynamic v2 JSON API loading with getModelName() function that constructs model names based on state parameter (e.g., ILEEIOv1.0-s-20 for Illinois)
  1. Empty Dropdown Values and Concentric Circles
  • Dropdowns showed empty text or stuck on "Jobs Supported"
  • Bubbles rendered as concentric circles due to undefined X-coordinates
  • Root Cause: ENRG (Energy Use) indicator doesn't exist in v2 state models
  • Added fallback logic to default to WATR/GHG/VADD if invalid indicators requested
  1. GHG Indicator Missing
  • Greenhouse Gases was filtered out in legacy code due to old data quality issues
  • Re-enabled GHG for v2 models since data is complete now
  1. No Dynamic State Switching
  • Changing state in URL required manual page refresh
  • Added both native hashchange listener and custom hashChangeEvent support
  • Chart now automatically reloads with D3 animations when state changes

New Features (Loren's Requests):

  1. Direct GitHub API Integration
  1. Red Bubble Highlighting for Top Industries
  • Loads each state's top 20 industries from community-data census
  • Maps 6-digit NAICS codes to v2 sector codes (e.g., "111CA", "561")
  • Automatically highlights top industries with red gradient
  • Changes dynamically when switching states
  • Follows same pattern as localsite/info/#state=IL

Technical Implementation:

  • State-specific filtering: Chart displays only the 73 sectors for selected state (excludes RoUS from visualization)
  • Dynamic indicator loading: Dropdowns repopulate when state changes
  • Reusable functions: Extracted loadIndicatorDropdowns() and loadTopIndustriesForState() for maintainability
  • NAICS to v2 sector mapping: mapNaicsToV2Sectors() handles conversion from 6-digit NAICS to v2 sector codes
  • Smooth D3 transitions when switching between states

Modified Files:

  • charts/bubble/js/bubble.js - Updated to load v2 JSON data dynamically from GitHub with red bubble highlighting

Removed Files:

  • build/api/ILEEIOv1.0-s-20/* - All 30 local JSON files removed per Loren's request (data now pulled from useeio-json repo)

Testing:

  • Tested with IL, GA, ME state models
  • Data loads successfully from GitHub useeio-json repository
  • Red bubbles highlight each state's top 20 industries correctly
  • Dynamic state switching works without manual refresh
  • All 3 dropdowns populate correctly and reflect URL parameters
  • Bubbles scatter properly with valid coordinates
  • Handles the 73-sector structure correctly
  • Smooth animations when switching states

Test URLs:

@ModelEarth ModelEarth merged commit 8fea92a into ModelEarth:main Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants