codeant-ai-for-open-source[bot] commented on code in PR #44628:
URL: https://github.com/apache/superset/pull/44628#discussion_r4109408239


##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -1209,6 +1212,59 @@ export function getMinAndMaxFromBounds(
   return {};
 }
 
+/**
+ * Computes a bar-width cap (px) sized to a temporal x-axis's own resolved
+ * time-grain bucket, instead of a flat constant that ignores how many
+ * pixels the grain actually spans on the rendered axis. Returns undefined
+ * when there isn't enough information to compute a grain-aware width (a
+ * non-temporal axis, no resolved grain outside TIMEGRAIN_TO_TIMESTAMP, or
+ * no data), so callers can fall back to their own default in that case.
+ *
+ * Uses getXAxisDomain โ€” the same data-extent estimate the x-axis label
+ * spacing formatter already relies on โ€” for the visible axis span. For two
+ * or more distinct x-values that's the real ECharts-rendered span (ECharts
+ * applies no padding there). For a single distinct value (domainMin ===
+ * domainMax), it falls back to 2 * ONE_DAY_MS, mirroring ECharts' own
+ * degenerate-domain padding for a time axis exactly (calcNiceForTimeScale
+ * in echarts/lib/scale/Time.js pads a single-point extent by ONE_DAY on
+ * each side, independent of grain) rather than guessing at a different
+ * span. This function does not change what range ECharts decides to
+ * render โ€” only how wide a bar is drawn within whatever range that already
+ * is.
+ *
+ * `plotLengthPx` must already be the pixel length of whichever screen
+ * dimension the temporal axis actually renders along โ€” callers are
+ * responsible for accounting for orientation (a horizontal bar chart swaps
+ * the temporal axis onto the chart's vertical/height dimension, not width;
+ * see the call sites in Timeseries/transformProps.ts and
+ * MixedTimeseries/transformProps.ts) before calling this.
+ */
+export function getGrainBarMaxWidth(
+  xAxisType: AxisType,
+  resolvedTimeGrain: string | undefined,
+  dataRecordArrays: Record<string, unknown>[][],
+  xAxisCol: string,
+  plotLengthPx: number,
+): number | undefined {
+  if (xAxisType !== AxisType.Time || !resolvedTimeGrain) {
+    return undefined;
+  }
+  const grainMs =
+    TIMEGRAIN_TO_TIMESTAMP[
+      resolvedTimeGrain as keyof typeof TIMEGRAIN_TO_TIMESTAMP
+    ];
+  if (!grainMs) {
+    return undefined;
+  }
+  const [domainMin, domainMax] = getXAxisDomain(dataRecordArrays, xAxisCol);
+  if (domainMin === undefined || domainMax === undefined) {
+    return undefined;

Review Comment:
   **Suggestion:** When temporal x values are ISO strings or `Date` objects, 
`getXAxisDomain` finds no numeric bounds, so this valid time axis keeps the old 
100-pixel bar cap.
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Sometimes` ยท ๐Ÿท๏ธ `Type error`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=c2bf5dedf4414939901bb2690b4d7db0&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=c2bf5dedf4414939901bb2690b4d7db0&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts
   **Line:** 1259:1261
   **Comment:**
        *Type Error: When temporal x values are ISO strings or `Date` objects, 
`getXAxisDomain` finds no numeric bounds, so this valid time axis keeps the old 
100-pixel bar cap.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44628&comment_hash=2940a454e634eb8b7573607da93e845d32715c7ad3e91b14bc5fecdef389d3f6&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44628&comment_hash=2940a454e634eb8b7573607da93e845d32715c7ad3e91b14bc5fecdef389d3f6&reaction=dislike'>๐Ÿ‘Ž</a>



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