MCPcopy Create free account
hub / github.com/CoderOpen/waimai / measureText

Function measureText

front/components/u-charts/u-charts.js:376–404  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

374}
375
376function measureText(text) {
377 var fontSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : config.fontSize;
378 text = String(text);
379 var text = text.split('');
380 var width = 0;
381 for (let i = 0; i < text.length; i++) {
382 let item = text[i];
383 if (/[a-zA-Z]/.test(item)) {
384 width += 7;
385 } else if (/[0-9]/.test(item)) {
386 width += 5.5;
387 } else if (/\./.test(item)) {
388 width += 2.7;
389 } else if (/-/.test(item)) {
390 width += 3.25;
391 } else if (/[\u4e00-\u9fa5]/.test(item)) {
392 width += 10;
393 } else if (/\(|\)/.test(item)) {
394 width += 3.73;
395 } else if (/\s/.test(item)) {
396 width += 2.5;
397 } else if (/%/.test(item)) {
398 width += 8;
399 } else {
400 width += 10;
401 }
402 }
403 return width * fontSize / 10;
404}
405
406function dataCombine(series) {
407 return series.reduce(function(a, b) {

Callers 15

getMaxTextListLengthFunction · 0.85
calLegendDataFunction · 0.85
calCategoriesDataFunction · 0.85
getPieTextMaxLengthFunction · 0.85
calYAxisDataFunction · 0.85
drawRingTitleFunction · 0.85
drawPointTextFunction · 0.85
drawGaugeLabelFunction · 0.85
drawRadarLabelFunction · 0.85
drawPieTextFunction · 0.85
drawToolTipSplitLineFunction · 0.85
drawMarkLineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected