File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed
Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change 339339 ] ;
340340
341341 let opts = {
342- title : 'Snap cursor to last ' ,
342+ title : 'Snap hover points (and/or cusror) to previous non-null ' ,
343343 width : 1000 ,
344344 height : 500 ,
345345 cursor : {
346+ // can use this if only snapping hover points, but keeping cursor at mouse coords
346347 hover : {
347348 bias : - 1 ,
348349 skip : [ null ] ,
349350 } ,
351+ /*
352+ // OR...
353+
354+ // this manually implements bias instead of relying on dataIdx/hover opts since they
355+ // are invoked later (and currently depend on the output coords of cursor.move)
356+ move: (u, mouseLeft, mouseTop) => {
357+ let curXVal = u.posToVal(mouseLeft, 'x');
358+ let curIdx = u.valToIdx(curXVal);
359+ let dataX = u.data[0];
360+ let dataY = u.data[1];
361+ let idxXVal = dataX[curIdx];
362+ let idxYVal = dataY[curIdx];
363+
364+ // backward bias
365+ if (curXVal < idxXVal || idxYVal == null) {
366+ while (curIdx > 0) {
367+ idxYVal = dataY[--curIdx];
368+
369+ if (idxYVal != null)
370+ break;
371+ }
372+ }
373+
374+ return [
375+ Math.round(u.valToPos(dataX[curIdx], 'x')),
376+ mouseTop,
377+ ];
378+ },
379+ */
350380 } ,
351381 scales : {
352382 x : {
You can’t perform that action at this time.
0 commit comments