MCPcopy Index your code
hub / github.com/bqplot/bqplot / computeDataIndices

Method computeDataIndices

js/src/Hist.ts:467–488  ·  view source on GitHub ↗
(indices)

Source from the content-addressed store, hash-verified

465 }
466
467 private computeDataIndices(indices) {
468 //input is a list of indices corresponding to the bars. Output is
469 //the list of indices in the data
470 const intervals = this.reduceIntervals(indices);
471 if (intervals.length === 0) {
472 return [];
473 }
474
475 const x_data = this.model.get('sample');
476 const num_intervals = intervals.length;
477 const indices_data = new Uint32Array(_.range(x_data.length));
478 const selected = indices_data.filter((index) => {
479 const elem = x_data[index];
480 for (let iter = 0; iter < num_intervals; iter++) {
481 if (elem <= intervals[iter][1] && elem >= intervals[iter][0]) {
482 return true;
483 }
484 }
485 return false;
486 });
487 return selected;
488 }
489
490 private reduceIntervals(indices: number[]) {
491 //for a series of indices, reduces them to the minimum possible

Callers 3

barClickHandlerMethod · 0.95
invert_pointMethod · 0.95
selector_changedMethod · 0.95

Calls 2

reduceIntervalsMethod · 0.95
rangeMethod · 0.80

Tested by

no test coverage detected