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

Method invert_point

js/src/Hist.ts:430–450  ·  view source on GitHub ↗
(pixel)

Source from the content-addressed store, hash-verified

428 }
429
430 invert_point(pixel) {
431 // Sets the selected to the data contained in the bin closest
432 // to the value of the pixel.
433 // Used by Index Selector.
434 if (pixel === undefined) {
435 this.model.set('selected', null);
436 this.touch();
437 return;
438 }
439
440 const bar_width = this.computeBarWidth();
441
442 //adding "bar_width / 2.0" to bin_pixels as we need to select the
443 //bar whose center is closest to the current location of the mouse.
444 const abs_diff = this.bin_pixels.map((elem) => {
445 return Math.abs(elem + bar_width / 2.0 - pixel);
446 });
447 const sel_index = abs_diff.indexOf(d3.min(abs_diff));
448 this.model.set('selected', this.computeDataIndices([sel_index]));
449 this.touch();
450 }
451
452 selector_changed(point_selector, rect_selector) {
453 if (point_selector === undefined) {

Callers 3

mousemoveMethod · 0.45
resetMethod · 0.45
selected_changedMethod · 0.45

Calls 2

computeBarWidthMethod · 0.95
computeDataIndicesMethod · 0.95

Tested by

no test coverage detected