amaannawab923 commented on code in PR #36416:
URL: https://github.com/apache/superset/pull/36416#discussion_r2665809248
##########
superset-frontend/packages/superset-ui-core/src/currency-format/utils.ts:
##########
@@ -76,14 +147,40 @@ export const getValueFormatter = (
d3Format: string | undefined,
currencyFormat: Currency | undefined,
key?: string,
+ data?: Record<string, any>[],
+ currencyCodeColumn?: string,
+ detectedCurrency?: string | null,
) => {
+ let resolvedCurrency: Currency | undefined | null = currencyFormat;
+ if (currencyFormat?.symbol === 'AUTO') {
+ // Use backend-detected currency, or fallback to frontend analysis
+ if (detectedCurrency !== undefined) {
+ resolvedCurrency = detectedCurrency
+ ? {
+ symbol: detectedCurrency,
+ symbolPosition: currencyFormat.symbolPosition,
+ }
+ : null;
+ } else if (data && currencyCodeColumn) {
+ const frontendDetected = analyzeCurrencyInData(data, currencyCodeColumn);
+ resolvedCurrency = frontendDetected
+ ? {
+ symbol: frontendDetected,
+ symbolPosition: currencyFormat.symbolPosition,
+ }
+ : null;
+ } else {
+ resolvedCurrency = null;
+ }
+ }
+
const customFormatter = getCustomFormatter(
buildCustomFormatters(
metrics,
savedCurrencyFormats,
savedColumnFormats,
d3Format,
- currencyFormat,
+ resolvedCurrency,
Review Comment:
can we perhaps name it to resolvedCurrencyFormat , since the variable was
previously named currentFormat
--
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]