(selected)
| 524 | } |
| 525 | |
| 526 | private dataIndexToBarIndex(selected) { |
| 527 | //function to calculate bar indices for a given list of data |
| 528 | //indices |
| 529 | if (selected === null) { |
| 530 | return null; |
| 531 | } |
| 532 | |
| 533 | const x_data = this.model.get('sample'); |
| 534 | const data = Array.from(selected).map((idx: number) => { |
| 535 | return x_data[idx]; |
| 536 | }); |
| 537 | let bar_indices = []; |
| 538 | for (let iter = 0; iter < data.length; iter++) { |
| 539 | //xBins is of length num_bars+1. So if the max element is |
| 540 | //selected, we get a bar index which is equal to num_bars. |
| 541 | let index = Math.min( |
| 542 | _.indexOf(this.model.xBins, data[iter], true), |
| 543 | this.model.xBins.length - 2 |
| 544 | ); |
| 545 | //if the data point is not one of the bins, then find the index |
| 546 | //where it is to be inserted. |
| 547 | if (index === -1) { |
| 548 | index = _.sortedIndex(this.model.xBins, data[iter]) - 1; |
| 549 | } |
| 550 | bar_indices.push(index); |
| 551 | } |
| 552 | bar_indices.sort(); |
| 553 | bar_indices = _.uniq(bar_indices, true); |
| 554 | return bar_indices; |
| 555 | } |
| 556 | |
| 557 | private resetSelection() { |
| 558 | this.selected_indices = []; |
no outgoing calls
no test coverage detected