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

Method _getLabelSize

src/scales/scale.time.js:591–603  ·  view source on GitHub ↗

* @param {string} label * @return {{w:number, h:number}} * @private

(label)

Source from the content-addressed store, hash-verified

589 * @private
590 */
591 _getLabelSize(label) {
592 const ticksOpts = this.options.ticks;
593 const tickLabelWidth = this.ctx.measureText(label).width;
594 const angle = toRadians(this.isHorizontal() ? ticksOpts.maxRotation : ticksOpts.minRotation);
595 const cosRotation = Math.cos(angle);
596 const sinRotation = Math.sin(angle);
597 const tickFontSize = this._resolveTickFontOptions(0).size;
598
599 return {
600 w: (tickLabelWidth * cosRotation) + (tickFontSize * sinRotation),
601 h: (tickLabelWidth * sinRotation) + (tickFontSize * cosRotation)
602 };
603 }
604
605 /**
606 * @param {number} exampleTime

Callers 1

_getLabelCapacityMethod · 0.95

Calls 3

toRadiansFunction · 0.85
isHorizontalMethod · 0.65

Tested by

no test coverage detected