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