(args)
| 263 | } |
| 264 | |
| 265 | private barClickHandler(args) { |
| 266 | const index = args.index; |
| 267 | //code repeated from bars. We should unify the two. |
| 268 | const idx = this.selected_indices; |
| 269 | let selected: number[] = idx ? utils.deepCopy(idx) : []; |
| 270 | // index of bar i. Checking if it is already present in the list. |
| 271 | const elem_index = selected.indexOf(index); |
| 272 | // Replacement for "Accel" modifier. |
| 273 | const accelKey = d3GetEvent().ctrlKey || d3GetEvent().metaKey; |
| 274 | if (elem_index > -1 && accelKey) { |
| 275 | // if the index is already selected and if accel key is |
| 276 | // pressed, remove the element from the list |
| 277 | selected.splice(elem_index, 1); |
| 278 | } else { |
| 279 | if (d3GetEvent().shiftKey) { |
| 280 | //If shift is pressed and the element is already |
| 281 | //selected, do not do anything |
| 282 | if (elem_index > -1) { |
| 283 | return; |
| 284 | } |
| 285 | //Add elements before or after the index of the current |
| 286 | //bar which has been clicked |
| 287 | const min_index = selected.length !== 0 ? d3.min(selected) : -1; |
| 288 | const max_index = |
| 289 | selected.length !== 0 |
| 290 | ? d3.max(selected) |
| 291 | : this.model.mark_data.length; |
| 292 | if (index > max_index) { |
| 293 | _.range(max_index + 1, index + 1).forEach((i) => { |
| 294 | selected.push(i); |
| 295 | }); |
| 296 | } else if (index < min_index) { |
| 297 | _.range(index, min_index).forEach((i) => { |
| 298 | selected.push(i); |
| 299 | }); |
| 300 | } |
| 301 | } else if (accelKey) { |
| 302 | //If accel is pressed and the bar is not already selected |
| 303 | //add the bar to the list of selected bars. |
| 304 | selected.push(index); |
| 305 | } |
| 306 | // updating the array containing the bar indexes selected |
| 307 | // and updating the style |
| 308 | else { |
| 309 | //if accel is not pressed, then clear the selected ones |
| 310 | //and set the current element to the selected |
| 311 | selected = []; |
| 312 | selected.push(index); |
| 313 | } |
| 314 | } |
| 315 | this.selected_indices = selected; |
| 316 | this.model.set( |
| 317 | 'selected', |
| 318 | selected.length === 0 ? null : this.computeDataIndices(selected), |
| 319 | { updated_view: this } |
| 320 | ); |
| 321 | this.touch(); |
| 322 | const e = d3GetEvent(); |
nothing calls this directly
no test coverage detected