From a242f94335435667f62c9c8615ed62cedc37f289 Mon Sep 17 00:00:00 2001 From: pah100 Date: Thu, 16 Jun 2016 02:16:39 +0800 Subject: [PATCH] fix title textAlign setting. --- src/component/title.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/component/title.js b/src/component/title.js index 7d438668e..07e3028d4 100644 --- a/src/component/title.js +++ b/src/component/title.js @@ -152,6 +152,11 @@ define(function(require) { if (textAlign === 'middle') { textAlign = 'center'; } + // If textAlign is illegal, canvas render text with textAlign 'left' and 'right' + // alternatively (after optimized that ctx.save/restore are not called if no change). + if (textAlign !== 'left' && textAlign !== 'right' && textAlign !== 'center') { + textAlign = 'left'; + } // Adjust layout by text align if (textAlign === 'right') { layoutRect.x += layoutRect.width; @@ -160,7 +165,8 @@ define(function(require) { layoutRect.x += layoutRect.width / 2; } } - group.position = [layoutRect.x, layoutRect.y]; + + group.attr('position', [layoutRect.x, layoutRect.y]); textEl.setStyle('textAlign', textAlign); subTextEl.setStyle('textAlign', textAlign); -- GitLab