codeant-ai-for-open-source[bot] commented on code in PR #26230:
URL: https://github.com/apache/superset/pull/26230#discussion_r2921904174
##########
superset-frontend/plugins/legacy-plugin-chart-calendar/src/Calendar.ts:
##########
@@ -98,10 +104,9 @@ function Calendar(element: HTMLElement, props:
CalendarProps) {
calContainer.text(`${METRIC_TEXT}: ${verboseMap[metric] || metric}`);
}
const timestamps = metricsData[metric];
- const rawExtents = d3Extent(
- Object.keys(timestamps),
- key => timestamps[key],
- );
+ const rawExtents = useCustomColorRange
+ ? ([colorRangeStart, colorRangeEnd - 1] as [number, number])
Review Comment:
**Suggestion:** The custom color range upper bound is decremented by 1
before building legend extents, which shifts the configured range and excludes
the user-specified max value. Use the exact end value so the chart reflects the
range users enter. [off-by-one]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Calendar Heatmap custom range legend excludes entered maximum.
- ⚠️ Color bins shift lower for custom range users.
```
</details>
```suggestion
? ([colorRangeStart, colorRangeEnd] as [number, number])
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Open Explore and select Calendar Heatmap (plugin registered in
`superset-frontend/src/visualizations/presets/MainPreset.ts:25,119` via
`CalendarChartPlugin`).
2. In chart options, set both custom range fields `color_range_start` and
`color_range_end` (defined in
`superset-frontend/plugins/legacy-plugin-chart-calendar/src/controlPanel.ts:141-153`)
and
run chart.
3. Rendering path sets `useCustomColorRange=true` when both fields are
present in
`superset-frontend/plugins/legacy-plugin-chart-calendar/src/transformProps.ts:48-52`,
then
passes values through at `:70-72`.
4. `Calendar` consumes those props and computes extents using `colorRangeEnd
- 1` at
`superset-frontend/plugins/legacy-plugin-chart-calendar/src/Calendar.ts:107-109`;
legend
values are generated from these extents at `:122`, so the configured max is
shifted down
by 1.
```
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/plugins/legacy-plugin-chart-calendar/src/Calendar.ts
**Line:** 108:108
**Comment:**
*Off By One: The custom color range upper bound is decremented by 1
before building legend extents, which shifts the configured range and excludes
the user-specified max value. Use the exact end value so the chart reflects the
range users enter.
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.
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F26230&comment_hash=041efc74cc95f05c69c199d639d8243499fa87a5c86846e836e3e5a11492f696&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F26230&comment_hash=041efc74cc95f05c69c199d639d8243499fa87a5c86846e836e3e5a11492f696&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]