Skip to content

Commit fe0cd3d

Browse files
committed
Use isNullOrUndef helper for point value checks
1 parent 76d2559 commit fe0cd3d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/core/core.interaction.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {_lookupByKey, _rlookupByKey} from '../helpers/helpers.collection.js';
22
import {getRelativePosition} from '../helpers/helpers.dom.js';
33
import {_angleBetween, getAngleFromPoint} from '../helpers/helpers.math.js';
4-
import {_isPointInArea} from '../helpers/index.js';
4+
import {_isPointInArea, isNullOrUndef} from '../helpers/index.js';
55

66
/**
77
* @typedef { import('./core.controller.js').default } Chart
@@ -36,13 +36,13 @@ function binarySearch(metaset, axis, value, intersect) {
3636
.slice(0, result.lo + 1)
3737
.reverse()
3838
.findIndex(
39-
point => point[vScale.axis] || point[vScale.axis] === 0));
39+
point => !isNullOrUndef(point[vScale.axis])));
4040
result.lo -= Math.max(0, distanceToDefinedLo);
4141

4242
const distanceToDefinedHi = (_parsed
4343
.slice(result.hi - 1)
4444
.findIndex(
45-
point => point[vScale.axis] || point[vScale.axis] === 0));
45+
point => !isNullOrUndef(point[vScale.axis])));
4646
result.hi += Math.max(0, distanceToDefinedHi);
4747
}
4848
return result;

src/helpers/helpers.extras.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {ChartMeta, PointElement} from '../types/index.js';
22

33
import {_limitValue} from './helpers.math.js';
44
import {_lookupByKey} from './helpers.collection.js';
5+
import {isNullOrUndef} from './helpers.core.js';
56

67
export function fontString(pixelSize: number, fontStyle: string, fontFamily: string) {
78
return fontStyle + ' ' + pixelSize + 'px ' + fontFamily;
@@ -107,7 +108,7 @@ export function _getStartAndCountOfVisiblePoints(meta: ChartMeta<'line' | 'scatt
107108
.slice(0, start + 1)
108109
.reverse()
109110
.findIndex(
110-
point => point[vScale.axis] || point[vScale.axis] === 0));
111+
point => !isNullOrUndef(point[vScale.axis])));
111112
start -= Math.max(0, distanceToDefinedLo);
112113
}
113114
start = _limitValue(start, 0, pointCount - 1);
@@ -122,7 +123,7 @@ export function _getStartAndCountOfVisiblePoints(meta: ChartMeta<'line' | 'scatt
122123
const distanceToDefinedHi = (_parsed
123124
.slice(end - 1)
124125
.findIndex(
125-
point => point[vScale.axis] || point[vScale.axis] === 0));
126+
point => !isNullOrUndef(point[vScale.axis])));
126127
end += Math.max(0, distanceToDefinedHi);
127128
}
128129
count = _limitValue(end, start, pointCount) - start;

0 commit comments

Comments
 (0)