-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[charts] Fix infinite tick number when zoom range is zero #17750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for adding a type label to the PR! 👍 |
Deploy preview: https://deploy-preview-17750--material-ui-x.netlify.app/ |
@@ -200,7 +200,9 @@ export function computeAxisValue<T extends ChartSeriesType>({ | |||
} | |||
|
|||
const rawTickNumber = getTickNumber({ ...axis, range, domain: axisExtremums }); | |||
const tickNumber = rawTickNumber / ((zoomRange[1] - zoomRange[0]) / 100); | |||
/* If the zoom start and end are the same, `tickNumber` will become infinity, so we should default to 1. */ | |||
const tickNumber = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to default to one tick because if zoom range is zero, there is no need to show more than one tick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have a test for this? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added 👍
CodSpeed Performance ReportMerging #17750 will not alter performanceComparing Summary
|
@@ -46,24 +46,6 @@ export interface TickParams { | |||
tickLabelPlacement?: 'middle' | 'tick'; | |||
} | |||
|
|||
export function getTickNumber( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to ticks
Fix infinite tick number when zoom range is zero.
This was causing a crash when the zoom range is zero (i.e., start === end) because d3's
scale.ticks
creates anArray(tickNumber)
which throws whentickNumber
isInfinity
.This might happen if the user sets
minSpan
to 0 or callssetZoomData
directly.