Text.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. import { __extends } from "tslib";
  2. import { parseRichText, parsePlainText } from './helper/parseText';
  3. import TSpan from './TSpan';
  4. import { retrieve2, each, normalizeCssArray, trim, retrieve3, extend, keys, defaults } from '../core/util';
  5. import { DEFAULT_FONT, adjustTextX, adjustTextY } from '../contain/text';
  6. import ZRImage from './Image';
  7. import Rect from './shape/Rect';
  8. import BoundingRect from '../core/BoundingRect';
  9. import Displayable, { DEFAULT_COMMON_ANIMATION_PROPS } from './Displayable';
  10. var DEFAULT_RICH_TEXT_COLOR = {
  11. fill: '#000'
  12. };
  13. var DEFAULT_STROKE_LINE_WIDTH = 2;
  14. export var DEFAULT_TEXT_ANIMATION_PROPS = {
  15. style: defaults({
  16. fill: true,
  17. stroke: true,
  18. fillOpacity: true,
  19. strokeOpacity: true,
  20. lineWidth: true,
  21. fontSize: true,
  22. lineHeight: true,
  23. width: true,
  24. height: true,
  25. textShadowColor: true,
  26. textShadowBlur: true,
  27. textShadowOffsetX: true,
  28. textShadowOffsetY: true,
  29. backgroundColor: true,
  30. padding: true,
  31. borderColor: true,
  32. borderWidth: true,
  33. borderRadius: true
  34. }, DEFAULT_COMMON_ANIMATION_PROPS.style)
  35. };
  36. var ZRText = (function (_super) {
  37. __extends(ZRText, _super);
  38. function ZRText(opts) {
  39. var _this = _super.call(this) || this;
  40. _this.type = 'text';
  41. _this._children = [];
  42. _this._defaultStyle = DEFAULT_RICH_TEXT_COLOR;
  43. _this.attr(opts);
  44. return _this;
  45. }
  46. ZRText.prototype.childrenRef = function () {
  47. return this._children;
  48. };
  49. ZRText.prototype.update = function () {
  50. _super.prototype.update.call(this);
  51. if (this.styleChanged()) {
  52. this._updateSubTexts();
  53. }
  54. for (var i = 0; i < this._children.length; i++) {
  55. var child = this._children[i];
  56. child.zlevel = this.zlevel;
  57. child.z = this.z;
  58. child.z2 = this.z2;
  59. child.culling = this.culling;
  60. child.cursor = this.cursor;
  61. child.invisible = this.invisible;
  62. }
  63. };
  64. ZRText.prototype.updateTransform = function () {
  65. var innerTransformable = this.innerTransformable;
  66. if (innerTransformable) {
  67. innerTransformable.updateTransform();
  68. if (innerTransformable.transform) {
  69. this.transform = innerTransformable.transform;
  70. }
  71. }
  72. else {
  73. _super.prototype.updateTransform.call(this);
  74. }
  75. };
  76. ZRText.prototype.getLocalTransform = function (m) {
  77. var innerTransformable = this.innerTransformable;
  78. return innerTransformable
  79. ? innerTransformable.getLocalTransform(m)
  80. : _super.prototype.getLocalTransform.call(this, m);
  81. };
  82. ZRText.prototype.getComputedTransform = function () {
  83. if (this.__hostTarget) {
  84. this.__hostTarget.getComputedTransform();
  85. this.__hostTarget.updateInnerText(true);
  86. }
  87. return _super.prototype.getComputedTransform.call(this);
  88. };
  89. ZRText.prototype._updateSubTexts = function () {
  90. this._childCursor = 0;
  91. normalizeTextStyle(this.style);
  92. this.style.rich
  93. ? this._updateRichTexts()
  94. : this._updatePlainTexts();
  95. this._children.length = this._childCursor;
  96. this.styleUpdated();
  97. };
  98. ZRText.prototype.addSelfToZr = function (zr) {
  99. _super.prototype.addSelfToZr.call(this, zr);
  100. for (var i = 0; i < this._children.length; i++) {
  101. this._children[i].__zr = zr;
  102. }
  103. };
  104. ZRText.prototype.removeSelfFromZr = function (zr) {
  105. _super.prototype.removeSelfFromZr.call(this, zr);
  106. for (var i = 0; i < this._children.length; i++) {
  107. this._children[i].__zr = null;
  108. }
  109. };
  110. ZRText.prototype.getBoundingRect = function () {
  111. if (this.styleChanged()) {
  112. this._updateSubTexts();
  113. }
  114. if (!this._rect) {
  115. var tmpRect = new BoundingRect(0, 0, 0, 0);
  116. var children = this._children;
  117. var tmpMat = [];
  118. var rect = null;
  119. for (var i = 0; i < children.length; i++) {
  120. var child = children[i];
  121. var childRect = child.getBoundingRect();
  122. var transform = child.getLocalTransform(tmpMat);
  123. if (transform) {
  124. tmpRect.copy(childRect);
  125. tmpRect.applyTransform(transform);
  126. rect = rect || tmpRect.clone();
  127. rect.union(tmpRect);
  128. }
  129. else {
  130. rect = rect || childRect.clone();
  131. rect.union(childRect);
  132. }
  133. }
  134. this._rect = rect || tmpRect;
  135. }
  136. return this._rect;
  137. };
  138. ZRText.prototype.setDefaultTextStyle = function (defaultTextStyle) {
  139. this._defaultStyle = defaultTextStyle || DEFAULT_RICH_TEXT_COLOR;
  140. };
  141. ZRText.prototype.setTextContent = function (textContent) {
  142. throw new Error('Can\'t attach text on another text');
  143. };
  144. ZRText.prototype._mergeStyle = function (targetStyle, sourceStyle) {
  145. if (!sourceStyle) {
  146. return targetStyle;
  147. }
  148. var sourceRich = sourceStyle.rich;
  149. var targetRich = targetStyle.rich || (sourceRich && {});
  150. extend(targetStyle, sourceStyle);
  151. if (sourceRich && targetRich) {
  152. this._mergeRich(targetRich, sourceRich);
  153. targetStyle.rich = targetRich;
  154. }
  155. else if (targetRich) {
  156. targetStyle.rich = targetRich;
  157. }
  158. return targetStyle;
  159. };
  160. ZRText.prototype._mergeRich = function (targetRich, sourceRich) {
  161. var richNames = keys(sourceRich);
  162. for (var i = 0; i < richNames.length; i++) {
  163. var richName = richNames[i];
  164. targetRich[richName] = targetRich[richName] || {};
  165. extend(targetRich[richName], sourceRich[richName]);
  166. }
  167. };
  168. ZRText.prototype.getAnimationStyleProps = function () {
  169. return DEFAULT_TEXT_ANIMATION_PROPS;
  170. };
  171. ZRText.prototype._getOrCreateChild = function (Ctor) {
  172. var child = this._children[this._childCursor];
  173. if (!child || !(child instanceof Ctor)) {
  174. child = new Ctor();
  175. }
  176. this._children[this._childCursor++] = child;
  177. child.__zr = this.__zr;
  178. child.parent = this;
  179. return child;
  180. };
  181. ZRText.prototype._updatePlainTexts = function () {
  182. var style = this.style;
  183. var textFont = style.font || DEFAULT_FONT;
  184. var textPadding = style.padding;
  185. var text = getStyleText(style);
  186. var contentBlock = parsePlainText(text, style);
  187. var needDrawBg = needDrawBackground(style);
  188. var bgColorDrawn = !!(style.backgroundColor);
  189. var outerHeight = contentBlock.outerHeight;
  190. var textLines = contentBlock.lines;
  191. var lineHeight = contentBlock.lineHeight;
  192. var defaultStyle = this._defaultStyle;
  193. var baseX = style.x || 0;
  194. var baseY = style.y || 0;
  195. var textAlign = style.align || defaultStyle.align || 'left';
  196. var verticalAlign = style.verticalAlign || defaultStyle.verticalAlign || 'top';
  197. var textX = baseX;
  198. var textY = adjustTextY(baseY, contentBlock.contentHeight, verticalAlign);
  199. if (needDrawBg || textPadding) {
  200. var outerWidth_1 = contentBlock.width;
  201. textPadding && (outerWidth_1 += textPadding[1] + textPadding[3]);
  202. var boxX = adjustTextX(baseX, outerWidth_1, textAlign);
  203. var boxY = adjustTextY(baseY, outerHeight, verticalAlign);
  204. needDrawBg && this._renderBackground(style, style, boxX, boxY, outerWidth_1, outerHeight);
  205. }
  206. textY += lineHeight / 2;
  207. if (textPadding) {
  208. textX = getTextXForPadding(baseX, textAlign, textPadding);
  209. if (verticalAlign === 'top') {
  210. textY += textPadding[0];
  211. }
  212. else if (verticalAlign === 'bottom') {
  213. textY -= textPadding[2];
  214. }
  215. }
  216. var defaultLineWidth = 0;
  217. var useDefaultFill = false;
  218. var textFill = getFill('fill' in style
  219. ? style.fill
  220. : (useDefaultFill = true, defaultStyle.fill));
  221. var textStroke = getStroke('stroke' in style
  222. ? style.stroke
  223. : (!bgColorDrawn
  224. && (!defaultStyle.autoStroke || useDefaultFill))
  225. ? (defaultLineWidth = DEFAULT_STROKE_LINE_WIDTH, defaultStyle.stroke)
  226. : null);
  227. var hasShadow = style.textShadowBlur > 0;
  228. var fixedBoundingRect = style.width != null
  229. && (style.overflow === 'truncate' || style.overflow === 'break' || style.overflow === 'breakAll');
  230. var calculatedLineHeight = contentBlock.calculatedLineHeight;
  231. for (var i = 0; i < textLines.length; i++) {
  232. var el = this._getOrCreateChild(TSpan);
  233. var subElStyle = el.createStyle();
  234. el.useStyle(subElStyle);
  235. subElStyle.text = textLines[i];
  236. subElStyle.x = textX;
  237. subElStyle.y = textY;
  238. if (textAlign) {
  239. subElStyle.textAlign = textAlign;
  240. }
  241. subElStyle.textBaseline = 'middle';
  242. subElStyle.opacity = style.opacity;
  243. subElStyle.strokeFirst = true;
  244. if (hasShadow) {
  245. subElStyle.shadowBlur = style.textShadowBlur || 0;
  246. subElStyle.shadowColor = style.textShadowColor || 'transparent';
  247. subElStyle.shadowOffsetX = style.textShadowOffsetX || 0;
  248. subElStyle.shadowOffsetY = style.textShadowOffsetY || 0;
  249. }
  250. if (textStroke) {
  251. subElStyle.stroke = textStroke;
  252. subElStyle.lineWidth = style.lineWidth || defaultLineWidth;
  253. subElStyle.lineDash = style.lineDash;
  254. subElStyle.lineDashOffset = style.lineDashOffset || 0;
  255. }
  256. if (textFill) {
  257. subElStyle.fill = textFill;
  258. }
  259. subElStyle.font = textFont;
  260. textY += lineHeight;
  261. if (fixedBoundingRect) {
  262. el.setBoundingRect(new BoundingRect(adjustTextX(subElStyle.x, style.width, subElStyle.textAlign), adjustTextY(subElStyle.y, calculatedLineHeight, subElStyle.textBaseline), style.width, calculatedLineHeight));
  263. }
  264. }
  265. };
  266. ZRText.prototype._updateRichTexts = function () {
  267. var style = this.style;
  268. var text = getStyleText(style);
  269. var contentBlock = parseRichText(text, style);
  270. var contentWidth = contentBlock.width;
  271. var outerWidth = contentBlock.outerWidth;
  272. var outerHeight = contentBlock.outerHeight;
  273. var textPadding = style.padding;
  274. var baseX = style.x || 0;
  275. var baseY = style.y || 0;
  276. var defaultStyle = this._defaultStyle;
  277. var textAlign = style.align || defaultStyle.align;
  278. var verticalAlign = style.verticalAlign || defaultStyle.verticalAlign;
  279. var boxX = adjustTextX(baseX, outerWidth, textAlign);
  280. var boxY = adjustTextY(baseY, outerHeight, verticalAlign);
  281. var xLeft = boxX;
  282. var lineTop = boxY;
  283. if (textPadding) {
  284. xLeft += textPadding[3];
  285. lineTop += textPadding[0];
  286. }
  287. var xRight = xLeft + contentWidth;
  288. if (needDrawBackground(style)) {
  289. this._renderBackground(style, style, boxX, boxY, outerWidth, outerHeight);
  290. }
  291. var bgColorDrawn = !!(style.backgroundColor);
  292. for (var i = 0; i < contentBlock.lines.length; i++) {
  293. var line = contentBlock.lines[i];
  294. var tokens = line.tokens;
  295. var tokenCount = tokens.length;
  296. var lineHeight = line.lineHeight;
  297. var remainedWidth = line.width;
  298. var leftIndex = 0;
  299. var lineXLeft = xLeft;
  300. var lineXRight = xRight;
  301. var rightIndex = tokenCount - 1;
  302. var token = void 0;
  303. while (leftIndex < tokenCount
  304. && (token = tokens[leftIndex], !token.align || token.align === 'left')) {
  305. this._placeToken(token, style, lineHeight, lineTop, lineXLeft, 'left', bgColorDrawn);
  306. remainedWidth -= token.width;
  307. lineXLeft += token.width;
  308. leftIndex++;
  309. }
  310. while (rightIndex >= 0
  311. && (token = tokens[rightIndex], token.align === 'right')) {
  312. this._placeToken(token, style, lineHeight, lineTop, lineXRight, 'right', bgColorDrawn);
  313. remainedWidth -= token.width;
  314. lineXRight -= token.width;
  315. rightIndex--;
  316. }
  317. lineXLeft += (contentWidth - (lineXLeft - xLeft) - (xRight - lineXRight) - remainedWidth) / 2;
  318. while (leftIndex <= rightIndex) {
  319. token = tokens[leftIndex];
  320. this._placeToken(token, style, lineHeight, lineTop, lineXLeft + token.width / 2, 'center', bgColorDrawn);
  321. lineXLeft += token.width;
  322. leftIndex++;
  323. }
  324. lineTop += lineHeight;
  325. }
  326. };
  327. ZRText.prototype._placeToken = function (token, style, lineHeight, lineTop, x, textAlign, parentBgColorDrawn) {
  328. var tokenStyle = style.rich[token.styleName] || {};
  329. tokenStyle.text = token.text;
  330. var verticalAlign = token.verticalAlign;
  331. var y = lineTop + lineHeight / 2;
  332. if (verticalAlign === 'top') {
  333. y = lineTop + token.height / 2;
  334. }
  335. else if (verticalAlign === 'bottom') {
  336. y = lineTop + lineHeight - token.height / 2;
  337. }
  338. var needDrawBg = !token.isLineHolder && needDrawBackground(tokenStyle);
  339. needDrawBg && this._renderBackground(tokenStyle, style, textAlign === 'right'
  340. ? x - token.width
  341. : textAlign === 'center'
  342. ? x - token.width / 2
  343. : x, y - token.height / 2, token.width, token.height);
  344. var bgColorDrawn = !!tokenStyle.backgroundColor;
  345. var textPadding = token.textPadding;
  346. if (textPadding) {
  347. x = getTextXForPadding(x, textAlign, textPadding);
  348. y -= token.height / 2 - textPadding[0] - token.innerHeight / 2;
  349. }
  350. var el = this._getOrCreateChild(TSpan);
  351. var subElStyle = el.createStyle();
  352. el.useStyle(subElStyle);
  353. var defaultStyle = this._defaultStyle;
  354. var useDefaultFill = false;
  355. var defaultLineWidth = 0;
  356. var textFill = getFill('fill' in tokenStyle ? tokenStyle.fill
  357. : 'fill' in style ? style.fill
  358. : (useDefaultFill = true, defaultStyle.fill));
  359. var textStroke = getStroke('stroke' in tokenStyle ? tokenStyle.stroke
  360. : 'stroke' in style ? style.stroke
  361. : (!bgColorDrawn
  362. && !parentBgColorDrawn
  363. && (!defaultStyle.autoStroke || useDefaultFill)) ? (defaultLineWidth = DEFAULT_STROKE_LINE_WIDTH, defaultStyle.stroke)
  364. : null);
  365. var hasShadow = tokenStyle.textShadowBlur > 0
  366. || style.textShadowBlur > 0;
  367. subElStyle.text = token.text;
  368. subElStyle.x = x;
  369. subElStyle.y = y;
  370. if (hasShadow) {
  371. subElStyle.shadowBlur = tokenStyle.textShadowBlur || style.textShadowBlur || 0;
  372. subElStyle.shadowColor = tokenStyle.textShadowColor || style.textShadowColor || 'transparent';
  373. subElStyle.shadowOffsetX = tokenStyle.textShadowOffsetX || style.textShadowOffsetX || 0;
  374. subElStyle.shadowOffsetY = tokenStyle.textShadowOffsetY || style.textShadowOffsetY || 0;
  375. }
  376. subElStyle.textAlign = textAlign;
  377. subElStyle.textBaseline = 'middle';
  378. subElStyle.font = token.font || DEFAULT_FONT;
  379. subElStyle.opacity = retrieve3(tokenStyle.opacity, style.opacity, 1);
  380. if (textStroke) {
  381. subElStyle.lineWidth = retrieve3(tokenStyle.lineWidth, style.lineWidth, defaultLineWidth);
  382. subElStyle.lineDash = retrieve2(tokenStyle.lineDash, style.lineDash);
  383. subElStyle.lineDashOffset = style.lineDashOffset || 0;
  384. subElStyle.stroke = textStroke;
  385. }
  386. if (textFill) {
  387. subElStyle.fill = textFill;
  388. }
  389. var textWidth = token.contentWidth;
  390. var textHeight = token.contentHeight;
  391. el.setBoundingRect(new BoundingRect(adjustTextX(subElStyle.x, textWidth, subElStyle.textAlign), adjustTextY(subElStyle.y, textHeight, subElStyle.textBaseline), textWidth, textHeight));
  392. };
  393. ZRText.prototype._renderBackground = function (style, topStyle, x, y, width, height) {
  394. var textBackgroundColor = style.backgroundColor;
  395. var textBorderWidth = style.borderWidth;
  396. var textBorderColor = style.borderColor;
  397. var isImageBg = textBackgroundColor && textBackgroundColor.image;
  398. var isPlainOrGradientBg = textBackgroundColor && !isImageBg;
  399. var textBorderRadius = style.borderRadius;
  400. var self = this;
  401. var rectEl;
  402. var imgEl;
  403. if (isPlainOrGradientBg || style.lineHeight || (textBorderWidth && textBorderColor)) {
  404. rectEl = this._getOrCreateChild(Rect);
  405. rectEl.useStyle(rectEl.createStyle());
  406. rectEl.style.fill = null;
  407. var rectShape = rectEl.shape;
  408. rectShape.x = x;
  409. rectShape.y = y;
  410. rectShape.width = width;
  411. rectShape.height = height;
  412. rectShape.r = textBorderRadius;
  413. rectEl.dirtyShape();
  414. }
  415. if (isPlainOrGradientBg) {
  416. var rectStyle = rectEl.style;
  417. rectStyle.fill = textBackgroundColor || null;
  418. rectStyle.fillOpacity = retrieve2(style.fillOpacity, 1);
  419. }
  420. else if (isImageBg) {
  421. imgEl = this._getOrCreateChild(ZRImage);
  422. imgEl.onload = function () {
  423. self.dirtyStyle();
  424. };
  425. var imgStyle = imgEl.style;
  426. imgStyle.image = textBackgroundColor.image;
  427. imgStyle.x = x;
  428. imgStyle.y = y;
  429. imgStyle.width = width;
  430. imgStyle.height = height;
  431. }
  432. if (textBorderWidth && textBorderColor) {
  433. var rectStyle = rectEl.style;
  434. rectStyle.lineWidth = textBorderWidth;
  435. rectStyle.stroke = textBorderColor;
  436. rectStyle.strokeOpacity = retrieve2(style.strokeOpacity, 1);
  437. rectStyle.lineDash = style.borderDash;
  438. rectStyle.lineDashOffset = style.borderDashOffset || 0;
  439. rectEl.strokeContainThreshold = 0;
  440. if (rectEl.hasFill() && rectEl.hasStroke()) {
  441. rectStyle.strokeFirst = true;
  442. rectStyle.lineWidth *= 2;
  443. }
  444. }
  445. var commonStyle = (rectEl || imgEl).style;
  446. commonStyle.shadowBlur = style.shadowBlur || 0;
  447. commonStyle.shadowColor = style.shadowColor || 'transparent';
  448. commonStyle.shadowOffsetX = style.shadowOffsetX || 0;
  449. commonStyle.shadowOffsetY = style.shadowOffsetY || 0;
  450. commonStyle.opacity = retrieve3(style.opacity, topStyle.opacity, 1);
  451. };
  452. ZRText.makeFont = function (style) {
  453. var font = '';
  454. if (style.fontSize || style.fontFamily || style.fontWeight) {
  455. var fontSize = '';
  456. if (typeof style.fontSize === 'string'
  457. && (style.fontSize.indexOf('px') !== -1
  458. || style.fontSize.indexOf('rem') !== -1
  459. || style.fontSize.indexOf('em') !== -1)) {
  460. fontSize = style.fontSize;
  461. }
  462. else if (!isNaN(+style.fontSize)) {
  463. fontSize = style.fontSize + 'px';
  464. }
  465. else {
  466. fontSize = '12px';
  467. }
  468. font = [
  469. style.fontStyle,
  470. style.fontWeight,
  471. fontSize,
  472. style.fontFamily || 'sans-serif'
  473. ].join(' ');
  474. }
  475. return font && trim(font) || style.textFont || style.font;
  476. };
  477. return ZRText;
  478. }(Displayable));
  479. var VALID_TEXT_ALIGN = { left: true, right: 1, center: 1 };
  480. var VALID_TEXT_VERTICAL_ALIGN = { top: 1, bottom: 1, middle: 1 };
  481. export function normalizeTextStyle(style) {
  482. normalizeStyle(style);
  483. each(style.rich, normalizeStyle);
  484. return style;
  485. }
  486. function normalizeStyle(style) {
  487. if (style) {
  488. style.font = ZRText.makeFont(style);
  489. var textAlign = style.align;
  490. textAlign === 'middle' && (textAlign = 'center');
  491. style.align = (textAlign == null || VALID_TEXT_ALIGN[textAlign]) ? textAlign : 'left';
  492. var verticalAlign = style.verticalAlign;
  493. verticalAlign === 'center' && (verticalAlign = 'middle');
  494. style.verticalAlign = (verticalAlign == null || VALID_TEXT_VERTICAL_ALIGN[verticalAlign]) ? verticalAlign : 'top';
  495. var textPadding = style.padding;
  496. if (textPadding) {
  497. style.padding = normalizeCssArray(style.padding);
  498. }
  499. }
  500. }
  501. function getStroke(stroke, lineWidth) {
  502. return (stroke == null || lineWidth <= 0 || stroke === 'transparent' || stroke === 'none')
  503. ? null
  504. : (stroke.image || stroke.colorStops)
  505. ? '#000'
  506. : stroke;
  507. }
  508. function getFill(fill) {
  509. return (fill == null || fill === 'none')
  510. ? null
  511. : (fill.image || fill.colorStops)
  512. ? '#000'
  513. : fill;
  514. }
  515. function getTextXForPadding(x, textAlign, textPadding) {
  516. return textAlign === 'right'
  517. ? (x - textPadding[1])
  518. : textAlign === 'center'
  519. ? (x + textPadding[3] / 2 - textPadding[1] / 2)
  520. : (x + textPadding[3]);
  521. }
  522. function getStyleText(style) {
  523. var text = style.text;
  524. text != null && (text += '');
  525. return text;
  526. }
  527. function needDrawBackground(style) {
  528. return !!(style.backgroundColor
  529. || style.lineHeight
  530. || (style.borderWidth && style.borderColor));
  531. }
  532. export default ZRText;