MCPcopy Create free account
hub / github.com/chartjs/Chart.js / drawTitle

Method drawTitle

src/core/core.scale.js:1590–1623  ·  view source on GitHub ↗

* @protected

()

Source from the content-addressed store, hash-verified

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

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