korbit-ai[bot] commented on code in PR #33723:
URL: https://github.com/apache/superset/pull/33723#discussion_r2135607002


##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:
##########
@@ -257,7 +258,22 @@ export default function transformProps(
     rawSeries.map(series => series.name as string),
   );
   const isAreaExpand = stack === StackControlsValue.Expand;
-  const xAxisDataType = dataTypes?.[xAxisLabel] ?? dataTypes?.[xAxisOrig];
+  let xAxisDataType = dataTypes?.[xAxisLabel] ?? dataTypes?.[xAxisOrig];
+
+  // Defensive check for xAxisDataType in case it is not provided by the 
backend.
+  if (xAxisDataType === undefined && data.length > 0) {
+    const firstValue = data[0][xAxisLabel];
+    if (
+      firstValue !== null &&
+      !Number.isNaN(new Date(firstValue as string | number).getTime())
+    ) {
+      console.warn(
+        `X-axis data type was missing from the backend response. ` +
+          `Successfully inferred a 'temporal' type from the data.`,
+      );

Review Comment:
   ### Direct console usage instead of logging framework <sub>![category 
Logging](https://img.shields.io/badge/Logging-4f46e5)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   Using console.warn() directly instead of a proper logging framework makes it 
harder to control log levels and format consistently across the application.
   
   
   ###### Why this matters
   Direct console usage can't be easily controlled in different environments 
(dev/prod), doesn't support structured logging, and may be stripped out by 
build tools.
   
   ###### Suggested change ∙ *Feature Preview*
   Replace with proper logging framework call:
   ```typescript
   logger.warn({
     message: 'X-axis data type was missing from the backend response. 
Successfully inferred a temporal type from the data.',
     xAxisLabel,
     inferredType: GenericDataType.Temporal,
   });
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice 
Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/bd4cde93-e017-4f84-b954-b2ba56606775/upvote)
 
[![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/bd4cde93-e017-4f84-b954-b2ba56606775?what_not_true=true)
  [![Not in 
Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/bd4cde93-e017-4f84-b954-b2ba56606775?what_out_of_scope=true)
 [![Not in coding 
standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/bd4cde93-e017-4f84-b954-b2ba56606775?what_not_in_standard=true)
 
[![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/bd4cde93-e017-4f84-b954-b2ba56606775)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:7367dfd5-64c7-493f-b043-df71bd6c07b6 -->
   
   
   [](7367dfd5-64c7-493f-b043-df71bd6c07b6)



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