MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / getWidth

Function getWidth

libs/echarts/echarts.simple.js:7602–7625  ·  view source on GitHub ↗

* @public * @param {string} text * @param {string} font * @return {number} width

(text, font)

Source from the content-addressed store, hash-verified

7600 * @return {number} width
7601 */
7602function getWidth(text, font) {
7603 font = font || DEFAULT_FONT$1;
7604 var key = text + ':' + font;
7605 if (textWidthCache[key]) {
7606 return textWidthCache[key];
7607 }
7608
7609 var textLines = (text + '').split('\n');
7610 var width = 0;
7611
7612 for (var i = 0, l = textLines.length; i < l; i++) {
7613 // textContain.measureText may be overrided in SVG or VML
7614 width = Math.max(measureText(textLines[i], font).width, width);
7615 }
7616
7617 if (textWidthCacheCounter > TEXT_CACHE_MAX) {
7618 textWidthCacheCounter = 0;
7619 textWidthCache = {};
7620 }
7621 textWidthCacheCounter++;
7622 textWidthCache[key] = width;
7623
7624 return width;
7625}
7626
7627/**
7628 * @public

Callers 9

getPlainTextRectFunction · 0.70
prepareTruncateOptionsFunction · 0.70
truncateSingleLineFunction · 0.70
getLineHeightFunction · 0.70
parseRichTextFunction · 0.70
renderPlainTextFunction · 0.70
loadingDefaultFunction · 0.70
avoidOverlapFunction · 0.70

Calls 2

maxMethod · 0.80
measureTextFunction · 0.70

Tested by

no test coverage detected