MCPcopy
hub / github.com/chartjs/Chart.js / drawTitle

Method drawTitle

src/core/core.scale.js:1588–1619  ·  view source on GitHub ↗

* @protected

()

Source from the content-addressed store, hash-verified

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()) {

Callers 2

drawMethod · 0.95
_layersMethod · 0.95

Calls 7

toFontFunction · 0.85
toPaddingFunction · 0.85
isObjectFunction · 0.85
isArrayFunction · 0.85
titleArgsFunction · 0.85
renderTextFunction · 0.85
titleAlignFunction · 0.85

Tested by

no test coverage detected