Skip to content

Commit b645963

Browse files
committed
only scan in-viewport data when hovering null values with hover bias
1 parent e1b3882 commit b645963

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

dist/uPlot.cjs.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3822,7 +3822,6 @@ function uPlot(opts, data, then) {
38223822
let prox = hov.prox = fnOrSelf(hov.prox);
38233823
let bias = hov.bias ??= 0;
38243824

3825-
// TODO: only scan between in-view idxs (i0, i1)
38263825
cursor.dataIdx = (self, seriesIdx, cursorIdx, valAtPosX) => {
38273826
if (seriesIdx == 0)
38283827
return cursorIdx;
@@ -3846,15 +3845,15 @@ function uPlot(opts, data, then) {
38463845

38473846
if (bias == 0 || bias == -1) {
38483847
j = cursorIdx;
3849-
while (nonNullLft == null && j-- > 0) {
3848+
while (nonNullLft == null && --j >= i0) {
38503849
if (!skip.has(yValues[j]))
38513850
nonNullLft = j;
38523851
}
38533852
}
38543853

38553854
if (bias == 0 || bias == 1) {
38563855
j = cursorIdx;
3857-
while (nonNullRgt == null && j++ < yValues.length) {
3856+
while (nonNullRgt == null && ++j <= i1) {
38583857
if (!skip.has(yValues[j]))
38593858
nonNullRgt = j;
38603859
}

dist/uPlot.esm.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3820,7 +3820,6 @@ function uPlot(opts, data, then) {
38203820
let prox = hov.prox = fnOrSelf(hov.prox);
38213821
let bias = hov.bias ??= 0;
38223822

3823-
// TODO: only scan between in-view idxs (i0, i1)
38243823
cursor.dataIdx = (self, seriesIdx, cursorIdx, valAtPosX) => {
38253824
if (seriesIdx == 0)
38263825
return cursorIdx;
@@ -3844,15 +3843,15 @@ function uPlot(opts, data, then) {
38443843

38453844
if (bias == 0 || bias == -1) {
38463845
j = cursorIdx;
3847-
while (nonNullLft == null && j-- > 0) {
3846+
while (nonNullLft == null && --j >= i0) {
38483847
if (!skip.has(yValues[j]))
38493848
nonNullLft = j;
38503849
}
38513850
}
38523851

38533852
if (bias == 0 || bias == 1) {
38543853
j = cursorIdx;
3855-
while (nonNullRgt == null && j++ < yValues.length) {
3854+
while (nonNullRgt == null && ++j <= i1) {
38563855
if (!skip.has(yValues[j]))
38573856
nonNullRgt = j;
38583857
}

dist/uPlot.iife.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3823,7 +3823,6 @@ var uPlot = (function () {
38233823
let prox = hov.prox = fnOrSelf(hov.prox);
38243824
let bias = hov.bias ??= 0;
38253825

3826-
// TODO: only scan between in-view idxs (i0, i1)
38273826
cursor.dataIdx = (self, seriesIdx, cursorIdx, valAtPosX) => {
38283827
if (seriesIdx == 0)
38293828
return cursorIdx;
@@ -3847,15 +3846,15 @@ var uPlot = (function () {
38473846

38483847
if (bias == 0 || bias == -1) {
38493848
j = cursorIdx;
3850-
while (nonNullLft == null && j-- > 0) {
3849+
while (nonNullLft == null && --j >= i0) {
38513850
if (!skip.has(yValues[j]))
38523851
nonNullLft = j;
38533852
}
38543853
}
38553854

38563855
if (bias == 0 || bias == 1) {
38573856
j = cursorIdx;
3858-
while (nonNullRgt == null && j++ < yValues.length) {
3857+
while (nonNullRgt == null && ++j <= i1) {
38593858
if (!skip.has(yValues[j]))
38603859
nonNullRgt = j;
38613860
}

dist/uPlot.iife.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uPlot.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,6 @@ export default function uPlot(opts, data, then) {
904904
let prox = hov.prox = fnOrSelf(hov.prox);
905905
let bias = hov.bias ??= 0;
906906

907-
// TODO: only scan between in-view idxs (i0, i1)
908907
cursor.dataIdx = (self, seriesIdx, cursorIdx, valAtPosX) => {
909908
if (seriesIdx == 0)
910909
return cursorIdx;
@@ -928,15 +927,15 @@ export default function uPlot(opts, data, then) {
928927

929928
if (bias == 0 || bias == -1) {
930929
j = cursorIdx;
931-
while (nonNullLft == null && j-- > 0) {
930+
while (nonNullLft == null && --j >= i0) {
932931
if (!skip.has(yValues[j]))
933932
nonNullLft = j;
934933
}
935934
}
936935

937936
if (bias == 0 || bias == 1) {
938937
j = cursorIdx;
939-
while (nonNullRgt == null && j++ < yValues.length) {
938+
while (nonNullRgt == null && ++j <= i1) {
940939
if (!skip.has(yValues[j]))
941940
nonNullRgt = j;
942941
}

0 commit comments

Comments
 (0)