-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[charts-pro] Refactor createAxisFilterMapper
#18998
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
[charts-pro] Refactor createAxisFilterMapper
#18998
Conversation
Deploy preview: https://deploy-preview-18998--material-ui-x.netlify.app/ Bundle size report
|
const axisData = ['I0', 'I1', 'I2', 'I3']; | ||
const filter = createDiscreteScaleGetAxisFilter(axisData, 24, 76, 'y'); | ||
|
||
expect(filter({ x: null, y: 'I0' }, 0)).toBe(false); |
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.
Here I0 and I3 are partially visible, so they should be included.
This is fixed in #18992.
createAxisFilterMapper
CodSpeed Performance ReportMerging #18998 will not alter performanceComparing Summary
|
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.
Much clearer 👍
const max = (axisData?.length ?? 1) - 1; | ||
|
||
[min, max] = getScale(continuousScaleType, extremums, [0, 100]).nice().domain(); | ||
const minVal = (zoomStart * max) / 100; | ||
const maxVal = (zoomEnd * max) / 100; |
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.
Just to clarify what kind of max it is
const max = (axisData?.length ?? 1) - 1; | |
[min, max] = getScale(continuousScaleType, extremums, [0, 100]).nice().domain(); | |
const minVal = (zoomStart * max) / 100; | |
const maxVal = (zoomEnd * max) / 100; | |
const maxIndex = (axisData?.length ?? 1) - 1; | |
const minVal = (zoomStart * maxIndex) / 100; | |
const maxVal = (zoomEnd * maxIndex) / 100; |
Refactored the functions for creating the axis filters. Now there's one for discrete scales and another one for continuous ones. It makes them easier to test and reason about IMO.
Also added tests.
I did this refactor as a precursor to a bug fix (PR here), but I want to test that PR more thoroughly first, so I moved the refactor into this PR.