Fix bar chart error with uniform column values#13590
Conversation
Handle multi-element arrays where all values are identical by checking minValue === maxValue instead of just chartData.length === 1. This allows charts with uniform values to render with appropriate y-axis bounds (e.g., [0, value] for positive uniform values) without throwing 'Invalid min/max y-axis configuration' error. Co-Authored-By: Claude <[email protected]>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where bar charts would throw an "Invalid min/max y-axis configuration" error when all values in a column were identical (uniform) but the array contained more than one element. The fix generalizes the existing single-element logic to handle all cases where minValue === maxValue.
Changes:
- Modified the condition from
chartData.length === 1tominValue === maxValueto handle uniform values regardless of array length - Added a descriptive comment explaining the purpose of the conditional block
- Removed an outdated inline comment
- Added comprehensive test coverage for uniform positive, zero, and negative values
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
frontend/lib/src/components/widgets/DataFrame/columns/ChartColumn.ts |
Changed the condition to detect uniform values by comparing min and max values instead of checking array length |
frontend/lib/src/components/widgets/DataFrame/columns/ChartColumn.test.ts |
Added test cases for uniform values (positive, zero, negative) without explicit y_min/y_max configuration |
SummaryThis PR fixes a bug (#13584) where bar charts with uniform (identical) values in a DataFrame column caused an "Invalid min/max y-axis configuration" error when no explicit Files changed:
Code QualityThe code change is minimal, targeted, and well-implemented: ChartColumn.ts (lines 207-215):
The fix is logically equivalent for single-element arrays (since a single element has Test CoverageUnit Tests (lines 265-286):
Relationship to existing tests:
E2E Coverage:
Backwards Compatibility✅ Fully backwards compatible:
Security & Risk✅ No security concerns identified:
✅ Low regression risk:
RecommendationsNo changes requested. The PR is well-implemented:
Minor observation (informational only):
VerdictAPPROVED: This is a well-implemented bug fix with comprehensive test coverage, minimal code changes, and no backwards compatibility concerns. The fix correctly generalizes the condition to handle all uniform-value arrays, not just single-element arrays. This is an automated AI review. Please verify the feedback and use your judgment. |
Describe your changes
Fixed the "Invalid min/max y-axis configuration" error that occurred when rendering bar charts with uniform (identical) values in a column without explicit y_min/y_max bounds. The fix changes the condition from checking single-element arrays to checking if all values are identical (minValue === maxValue), applying the same bounds logic to both cases.
GitHub Issue Link
Fixes #13584
Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.