You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "doctorseus (via GitHub)" <gi...@apache.org> on 2024/04/24 11:14:36 UTC

Re: [I] Map crossfilter doesn't work [superset]

doctorseus commented on issue #25212:
URL: https://github.com/apache/superset/issues/25212#issuecomment-2074701437

   This is still broken on master so the ticket should reopend. @rusackas might only have tested the "Full name" option as it is handled separately in an extra code path: https://github.com/apache/superset/blob/9db431b4303fb83b79584d254bd0344ade117381/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js#L118
   
   But as seen here, the "country" field will always have the cca3 value. That is indeed required for visualization: https://github.com/apache/superset/blob/9db431b4303fb83b79584d254bd0344ade117381/superset/viz.py#L1564
    
   But to use a crossfilter it is required to also forward the actual value of the row to hand back to the filter, this is the patch we are using which fixes the issues:
   
   ```
   diff --git a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js
   index 540097be2..c866486fd 100644
   --- a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js
   +++ b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js
   @@ -30,6 +30,7 @@ import { ColorBy } from './utils';
    const propTypes = {
      data: PropTypes.arrayOf(
        PropTypes.shape({
   +      value: PropTypes.string,
          country: PropTypes.string,
          latitude: PropTypes.number,
          longitude: PropTypes.number,
   @@ -114,8 +115,7 @@ function WorldMap(element, props) {
      const getCrossFilterDataMask = source => {
        const selected = Object.values(filterState.selectedValues || {});
        const key = source.id || source.country;
   -    const country =
   -      countryFieldtype === 'name' ? mapData[key]?.name : mapData[key]?.country;
   +    const country = mapData[key]?.value;
    
        if (!country) {
          return undefined;
   diff --git a/superset/viz.py b/superset/viz.py
   index 8ba785ddc..b5ef29119 100644
   --- a/superset/viz.py
   +++ b/superset/viz.py
   @@ -1608,6 +1608,7 @@ class WorldMapViz(BaseViz):
                            self.form_data["country_fieldtype"], row["country"]
                        )
                if country:
   +                row["value"] = row["country"]
                    row["country"] = country["cca3"]
                    row["latitude"] = country["lat"]
                    row["longitude"] = country["lng"]
   ```
   
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org