(pixel)
| 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) { |
no test coverage detected