* @protected
()
| 1586 | * @protected |
| 1587 | */ |
| 1588 | drawTitle() { |
| 1589 | const {ctx, options: {position, title, reverse}} = this; |
| 1590 | |
| 1591 | if (!title.display) { |
| 1592 | return; |
| 1593 | } |
| 1594 | |
| 1595 | const font = toFont(title.font); |
| 1596 | const padding = toPadding(title.padding); |
| 1597 | const align = title.align; |
| 1598 | let offset = font.lineHeight / 2; |
| 1599 | |
| 1600 | if (position === 'bottom' || position === 'center' || isObject(position)) { |
| 1601 | offset += padding.bottom; |
| 1602 | if (isArray(title.text)) { |
| 1603 | offset += font.lineHeight * (title.text.length - 1); |
| 1604 | } |
| 1605 | } else { |
| 1606 | offset += padding.top; |
| 1607 | } |
| 1608 | |
| 1609 | const {titleX, titleY, maxWidth, rotation} = titleArgs(this, offset, position, align); |
| 1610 | |
| 1611 | renderText(ctx, title.text, 0, 0, font, { |
| 1612 | color: title.color, |
| 1613 | maxWidth, |
| 1614 | rotation, |
| 1615 | textAlign: titleAlign(align, position, reverse), |
| 1616 | textBaseline: 'middle', |
| 1617 | translation: [titleX, titleY], |
| 1618 | }); |
| 1619 | } |
| 1620 | |
| 1621 | draw(chartArea) { |
| 1622 | if (!this._isVisible()) { |
no test coverage detected