yong1le opened a new pull request, #35919:
URL: https://github.com/apache/superset/pull/35919

   ### SUMMARY
   
   #### `superset/viz.py`
   The backend currently provides country results to the frontend in the format:
   ```jsonc
   {
       "country": "string",
       "name": "string",
       // … other fields  
   }
   ```
   The country field is the `cca3` code of the country, and name is the 
country’s full name. country must be sent as a `cca3` code, because the 
frontend plugin used for maps only recognizes `cca3` country codes. To improve 
interoperability and make additional code formats (e.g., `cca2`, `cioc`) 
available without altering the existing response structure, we introduce an 
additional object field codes:
   ```jsonc
   {
       "country": "string",
       "name": "string",
       "codes": {
           "cca2": "string",
           "cca3": "string",
           "cioc": "string"
       }
   // … other fields  
   }
   ```
   This approach was chosen because it preserves backward compatibility with 
existing frontend expectations (country remains `cca3`).
   
   #### 
`superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js`
   This frontend component handles the world map chart and manages cross-filter 
interactions through the `getCrossFilterDataMask` function, which is triggered 
when a user clicks on a country. Previously, `getCrossFilterDataMask` only 
checked if `countryFieldType == "name"`.
   
   If `countryFieldType == "name"`, it used the backend `name` field (e.g., 
"Canada"). Otherwise, it used the `country` field, which was always in `cca3` 
format (e.g., "CAN"). Since `countryFieldType` supports four known values 
(`name`, `cca3`, `cca2`, and `cioc`), the `cca2` and `cioc` cases were 
effectively ignored. We refactored the logic to handle all four 
`countryFieldType` options by using the codes object returned from the backend. 
   
   ### TESTING INSTRUCTIONS
   
   #### Steps to Verify:
   1. Create a dataset that includes country identifier fields (e.g., name, 
`cca2`).
   2. Create two world map charts using these datasets with the 
countryFieldType as `cca2`.
   3. Add both charts to the same dashboard.
   4. Interact with the maps by selecting a country.
   
   #### Expected Result:
   Observe that when you click on a country in one map, the corresponding 
country is highlighted in all other maps.
   
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [x] Has associated issue: <!--- Fixes #34024 -->
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to