aminghadersohi commented on code in PR #44148:
URL: https://github.com/apache/superset/pull/44148#discussion_r4152808891
##########
superset-frontend/plugins/plugin-chart-country-map/src/CountryMap.ts:
##########
@@ -178,6 +182,11 @@ function CountryMap(element: HTMLElement, props:
CountryMapProps) {
// Track mouse position to distinguish clicks from drags
let mousedownPos: { x: number; y: number } | null = null;
+ const sourceValue = (code: string) =>
+ sourceValues && Object.prototype.hasOwnProperty.call(sourceValues, code)
+ ? sourceValues[code]
Review Comment:
Fixed in ac2bee524a3b2cef862794af493753bd857ca5fa. Explicit-format maps no
longer emit guessed identifiers for boundaries absent from the source-value
mapping. Native ISO-format behavior is preserved. The CA-only regression clicks
and right-clicks Texas and verifies that neither cross-filter nor drill actions
are emitted.
The regression was reproduced with a failing test before the fix.
Validation: 123 country-map/world-map Jest tests passed; 3,069 chart unit tests
passed (3 skipped); touched-file pre-commit passed.
##########
superset-frontend/plugins/plugin-chart-world-map/src/countries.ts:
##########
@@ -2010,21 +2010,44 @@ export const countries: CountryInfo[] = [
},
];
-const lookups: Record<CountryFieldType, Map<string, CountryInfo>> = {
- name: new Map(),
+/** Match country names without guessing or folding short country codes. */
+function foldName(value: string): string {
+ return value
+ .toLowerCase()
+ .normalize('NFD')
+ .replace(/[\u0300-\u036F]/g, '');
+}
+
+const exactNames = new Map(countries.map(country => [country.name, country]));
+const foldedNames = new Map<string, CountryInfo[]>();
+// Names resolve through exactNames/foldedNames; codes match
case-insensitively.
+type CountryCodeField = Exclude<CountryFieldType, 'name'>;
+const lookups: Record<CountryCodeField, Map<string, CountryInfo>> = {
cca2: new Map(),
cca3: new Map(),
cioc: new Map(),
};
-(Object.keys(lookups) as CountryFieldType[]).forEach(field => {
+(Object.keys(lookups) as CountryCodeField[]).forEach(field => {
countries.forEach(country => {
lookups[field].set(country[field].toLowerCase(), country);
});
});
+countries.forEach(country => {
+ const key = foldName(country.name);
+ const matches = foldedNames.get(key) ?? [];
+ matches.push(country);
+ foldedNames.set(key, matches);
+});
export function getCountry(
field: string,
symbol: string,
): CountryInfo | undefined {
- return lookups[field as CountryFieldType]?.get(symbol.toLowerCase());
+ if (field === 'name') {
+ const exact = exactNames.get(symbol);
+ if (exact) return exact;
+ const matches = foldedNames.get(foldName(symbol));
Review Comment:
Fixed in ac2bee524a3b2cef862794af493753bd857ca5fa. World-map rows retain the
original source value separately from the normalized rendering code and display
name. Both cross-filter and drill actions use that original value. Interaction
regressions cover Curaçao, CURAÇAO, and lowercase fr.
The regression was reproduced with a failing test before the fix.
Validation: 123 country-map/world-map Jest tests passed; 3,069 chart unit tests
passed (3 skipped); touched-file pre-commit passed.
##########
superset-frontend/plugins/plugin-chart-world-map/src/transformData.ts:
##########
@@ -66,6 +74,28 @@ export default function transformData(
typeof row.country === 'string' && fieldtype
? getCountry(fieldtype, row.country)
: undefined;
Review Comment:
Fixed in ac2bee524a3b2cef862794af493753bd857ca5fa. Blank country identifiers
are rejected before lookup, and empty country codes are excluded from the
lookup tables. The cioc regression rejects the empty value in strict rendering
instead of shading New Caledonia; non-strict rendering leaves it unmatched.
The regression was reproduced with a failing test before the fix.
Validation: 123 country-map/world-map Jest tests passed; 3,069 chart unit tests
passed (3 skipped); touched-file pre-commit passed.
##########
superset/mcp_service/chart/plugins/__init__.py:
##########
@@ -82,3 +90,7 @@
"WaterfallChartPlugin",
"XYChartPlugin",
]
+
+register(CountryMapChartPlugin())
Review Comment:
Fixed in ac2bee524a3b2cef862794af493753bd857ca5fa. Disabled-plugin access is
restricted to a loaded cached preview of the same chart type. Fresh previews,
expired cache keys, and type conversions enforce availability. Regression tests
cover all three geographic types and confirm that same-type iteration remains
supported.
The regression was reproduced with a failing test before the fix.
Validation: 123 country-map/world-map Jest tests passed; 3,069 chart unit tests
passed (3 skipped); touched-file pre-commit passed.
--
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]