-
Notifications
You must be signed in to change notification settings - Fork 331
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
Breaking change in fixRange method #928
Comments
i'm using [email protected] All date/time values i have use this same format |
Looks like I forgot to apply scale.parse to the min/max option. |
joshkel
added a commit
to joshkel/Chart.js
that referenced
this issue
Feb 15, 2025
While investigating chartjs/chartjs-plugin-zoom#928, I found that `isNonPrimitive` will throw TypeError on a Moment.js object after it's passed through Chart.js's options proxy, because the value has its `Symbol.toPrimitive`, `toString`, and `valueOf` all set to null. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_coercion. Since isNumber appears to be a low-level function that can take any arbitrary input, it seems worth letting it handle this case.
joshkel
added a commit
to joshkel/Chart.js
that referenced
this issue
Feb 15, 2025
While investigating chartjs/chartjs-plugin-zoom#928, I found that `isNonPrimitive` will throw TypeError on a Moment.js object after it's passed through Chart.js's options proxy, because the object has its `Symbol.toPrimitive`, `toString`, and `valueOf` all set to null. (See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_coercion for background reading.) Since isNumber appears to be a low-level function that can take any arbitrary input, it seems worth letting it handle this case.
etimberg
pushed a commit
to chartjs/Chart.js
that referenced
this issue
Feb 16, 2025
While investigating chartjs/chartjs-plugin-zoom#928, I found that `isNonPrimitive` will throw TypeError on a Moment.js object after it's passed through Chart.js's options proxy, because the object has its `Symbol.toPrimitive`, `toString`, and `valueOf` all set to null. (See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_coercion for background reading.) Since isNumber appears to be a low-level function that can take any arbitrary input, it seems worth letting it handle this case.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When running this code:
function fixRange(range, {min, max, minLimit, maxLimit}, originalLimits) { const offset = (range - max + min) / 2; min -= offset; max += offset; const origMin = originalLimits.min.options ?? originalLimits.min.scale; const origMax = originalLimits.max.options ?? originalLimits.max.scale; const epsilon = range / 1e6; if (helpers.almostEquals(min, origMin, epsilon)) { min = origMin; } if (helpers.almostEquals(max, origMax, epsilon)) { max = origMax; } if (min < minLimit) { min = minLimit; max = Math.min(minLimit + range, maxLimit); } else if (max > maxLimit) { max = maxLimit; min = Math.max(maxLimit - range, minLimit); } return {min, max}; }
originalLimits.min.options is a object, causing the helpers.almostEquals() to throw a exception.
My code is made for version V2.0.1 and did work perfectly then, but does not work for V2.1.0 or V2.2.0.
Any breaking changes in the code implementation since then?
This is my implementation of ChartJs
`chart = new Chart($('#uicabbd488c7ab04e589f591f67ebbfcd4c')[0], {
type: 'line',
The text was updated successfully, but these errors were encountered: