justinpark commented on code in PR #38191:
URL: https://github.com/apache/superset/pull/38191#discussion_r2991955586


##########
superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx:
##########
@@ -843,7 +843,7 @@ export class TableRenderer extends Component<
           );
         };
         const headerCellFormattedValue =
-          dateFormatters?.[attrName]?.(colKey[attrIdx]) ?? colKey[attrIdx];
+          dateFormatters?.[attrName]?.(Number(colKey[attrIdx])) ?? 
colKey[attrIdx];

Review Comment:
   This approach seems likely to cause issues when formatting string (str) 
values (for example, 'Dec. 16 2020'). How about creating and using a function 
that converts to a number only when the string 
   is a numeric string?
   
   
   ```suggestion
   function convertToNumberIfNumeric(value: string) {
     if (value.trim() !== '' && !isNaN(value)) {
       return Number(value);
     }
     return value
   }
   
             
dateFormatters?.[attrName]?.(convertToNumberIfNumeric(colKey[attrIdx])) ?? 
colKey[attrIdx];
   ```



-- 
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