bito-code-review[bot] commented on code in PR #35033:
URL: https://github.com/apache/superset/pull/35033#discussion_r2325730254
##########
superset-frontend/plugins/legacy-preset-chart-deckgl/src/utils.ts:
##########
@@ -78,16 +78,28 @@ export function getBreakPoints(
const delta = (maxValue - minValue) / numBuckets;
const precision =
delta === 0 ? 0 : Math.max(0, Math.ceil(Math.log10(1 / delta)));
- const extraBucket =
- maxValue > parseFloat(maxValue.toFixed(precision)) ? 1 : 0;
- const startValue =
- minValue < parseFloat(minValue.toFixed(precision))
- ? minValue - 1
- : minValue;
- return new Array(numBuckets + 1 + extraBucket)
+ // Generate breakpoints
+ const breakPoints = new Array(numBuckets + 1)
.fill(0)
- .map((_, i) => (startValue + i * delta).toFixed(precision));
+ .map((_, i) => {
+ const value = minValue + i * delta;
+ // For the first breakpoint, use the actual min value
+ if (i === 0) {
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>First breakpoint excludes minimum values</b></div>
<div id="fix">
Critical bug in first breakpoint generation: `minValue.toFixed(precision)`
can produce a value greater than the original `minValue` due to rounding. This
causes data points equal to `minValue` to be excluded from all buckets and
rendered as transparent. Fix by checking if the rounded value exceeds
`minValue` and adjusting it downward when needed.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```suggestion
// For the first breakpoint, use the actual min value
if (i === 0) {
const rounded = parseFloat(minValue.toFixed(precision));
// Ensure first breakpoint is <= minValue to include all data
points
return rounded > minValue
? (minValue - Math.pow(10, -precision)).toFixed(precision)
: minValue.toFixed(precision);
```
</div>
</details>
</div>
<small><i>Code Review Run <a
href=https://github.com/apache/superset/pull/35033#issuecomment-3259281742>#e00bcf</a></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]