chartjs / chartjs/chartjs-plugin-datalabels
nullPtr exception in orient()
- Dominant language
- JavaScript
- Stars
- 920
- Forks
- 507
- PR merge metrics
- No merged PRs in 30d
Description
Not sure why or how, but when i use this plugin, i get a null pointer exception when accessing 'origin' on first paint of the animation. By using the ?. operator, it works. The codebase i use is complex and i haven't had a chance to create a simple usecase and i don't quite understand the underlying logic much either.
But this bandaid works it seems 😄
```js
function orient(point, origin) {
var x0 = origin?.x;
var y0 = origin?.y;
if (x0 === null) {
return {x: 0, y: -1};
}
if (y0 === null) {
return {x: 1, y: 0};
}
var dx = point.x - x0;
var dy = point.y - y0;
var ln = Math.sqrt(dx * dx + dy * dy);
return {
x: ln ? dx / ln : 0,
y: ln ? dy / ln : -1
};
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.