()
| 442 | } |
| 443 | |
| 444 | adjustHitBoxes() { |
| 445 | if (!this.options.display) { |
| 446 | return; |
| 447 | } |
| 448 | const titleHeight = this._computeTitleHeight(); |
| 449 | const {legendHitBoxes: hitboxes, legendItems, options: {align, rtl, labels: {padding, textAlign: labelAlign}}} = this; |
| 450 | const rtlHelper = getRtlAdapter(rtl, this.left, this.width); |
| 451 | const placement: ItemPlacement = {layout: this._labelLayout, rtlHelper, rtl}; |
| 452 | if (this.isHorizontal()) { |
| 453 | let row = 0; |
| 454 | let left = _alignStartEnd(align, this.left + padding, this.right - this.lineWidths[row]); |
| 455 | for (let i = 0; i < hitboxes.length; i++) { |
| 456 | const hitbox = hitboxes[i]; |
| 457 | if (row !== hitbox.row) { |
| 458 | row = hitbox.row; |
| 459 | left = _alignStartEnd(align, this.left + padding, this.right - this.lineWidths[row]); |
| 460 | } |
| 461 | hitbox.top += this.top + titleHeight + padding; |
| 462 | placeItem(placement, hitbox, applyItemTextAlign(legendItems[i], labelAlign), left, left + hitbox.width); |
| 463 | hitbox.left = rtlHelper.leftForLtr(rtlHelper.x(left), hitbox.width); |
| 464 | left += hitbox.width + padding; |
| 465 | } |
| 466 | } else { |
| 467 | let col = 0; |
| 468 | let top = _alignStartEnd(align, this.top + titleHeight + padding, this.bottom - this.columnSizes[col].height); |
| 469 | for (let i = 0; i < hitboxes.length; i++) { |
| 470 | const hitbox = hitboxes[i]; |
| 471 | if (hitbox.col !== col) { |
| 472 | col = hitbox.col; |
| 473 | top = _alignStartEnd(align, this.top + titleHeight + padding, this.bottom - this.columnSizes[col].height); |
| 474 | } |
| 475 | hitbox.top = top; |
| 476 | // The left edge from fit(), before the aligned text moves the hit box. |
| 477 | const x = hitbox.left + this.left + padding; |
| 478 | const right = this._columnRight(x, col); |
| 479 | const textAlign = applyItemTextAlign(legendItems[i], labelAlign); |
| 480 | placeItem(placement, hitbox, textAlign, x, right); |
| 481 | coverAlignedText(placement, hitbox, textAlign, x, right); |
| 482 | top += hitbox.height + padding; |
| 483 | } |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | /** |
| 488 | * End of a vertical legend column's text area: the next column's left edge |
no test coverage detected