UNPKG

@antv/g2plot

Version:

G2 Plot, a market of plots built with the Grammar of Graphics'

37 lines 910 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); /** * 判断text是否可用, title description * * @param source */ function isTextUsable(source) { if (!source) return false; if (source.visible === true && typeof source.text === 'string' && source.text.trim()) return true; return false; } exports.isTextUsable = isTextUsable; /** * 为字符串添加换行符 * @param source - 字符串数组 ['a', 'b', 'c'] * @param breaks - 要添加换行的index * * @example * ```js * breakText(['a','b','c'], [1]) * * // a\nbc * ``` */ function breakText(source, breaks) { var result = tslib_1.__spreadArrays(source); breaks.forEach(function (pos, index) { result.splice(pos + index, 0, '\n'); }); return result.join(''); } exports.breakText = breakText; //# sourceMappingURL=common.js.map