bito-code-review[bot] commented on code in PR #38126:
URL: https://github.com/apache/superset/pull/38126#discussion_r2836077788


##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts:
##########
@@ -655,14 +680,27 @@ export function transformTimeseriesAnnotation(
 ): SeriesOption[] {
   const series: SeriesOption[] = [];
   const { hideLine, name, opacity, showMarkers, style, width, color } = layer;
+
+  const shiftMs = parseTimeShiftToMs((layer as any)?.overrides?.time_shift);
+
   const result = annotationData[name];
   const isHorizontal = orientation === OrientationType.Horizontal;
   const { records } = result;
   if (records) {
     const data = records.map(record => {
       const keys = Object.keys(record);
-      const x = keys.length > 0 ? record[keys[0]] : 0;
+
+      let x = keys.length > 0 ? record[keys[0]] : 0;
       const y = keys.length > 1 ? record[keys[1]] : 0;
+
+      if (shiftMs !== 0 && x != null) {
+        const xMs = typeof x === 'string' ? new Date(x).getTime() : Number(x);
+
+        if (!Number.isNaN(xMs)) {
+          x = xMs + shiftMs;
+        }
+      }

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Add tests for time_shift feature</b></div>
   <div id="fix">
   
   The new time_shift feature in transformTimeseriesAnnotation lacks test 
coverage. Existing tests in transformers.test.ts verify data transformation but 
don't test the time shifting logic added here.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #aee9e6</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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