You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2019/01/09 17:12:12 UTC
[incubator-echarts] branch master updated: Support
textVerticalAlign as the alias as textBaseline in title component.
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
The following commit(s) were added to refs/heads/master by this push:
new 1898edb Support textVerticalAlign as the alias as textBaseline in title component.
1898edb is described below
commit 1898edbc3030251b3b645338ea21de7f8ab3673b
Author: sushuang <su...@gmail.com>
AuthorDate: Thu Jan 10 01:11:43 2019 +0800
Support textVerticalAlign as the alias as textBaseline in title component.
---
src/component/title.js | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/component/title.js b/src/component/title.js
index 00f62b8..5dc5fff 100644
--- a/src/component/title.js
+++ b/src/component/title.js
@@ -17,6 +17,7 @@
* under the License.
*/
+import * as zrUtil from 'zrender/src/core/util';
import * as echarts from '../echarts';
import * as graphic from '../util/graphic';
import {getLayoutRect} from '../util/layout';
@@ -62,7 +63,8 @@ echarts.extendComponentModel({
// 垂直对齐
// 'auto' | 'top' | 'bottom' | 'middle'
// 默认根据 top 位置判断是上对齐还是下对齐
- // textBaseline: null
+ // textVerticalAlign: null
+ // textBaseline: null // The same as textVerticalAlign.
backgroundColor: 'rgba(0,0,0,0)',
@@ -107,7 +109,9 @@ echarts.extendComponentView({
var subtextStyleModel = titleModel.getModel('subtextStyle');
var textAlign = titleModel.get('textAlign');
- var textBaseline = titleModel.get('textBaseline');
+ var textVerticalAlign = zrUtil.retrieve2(
+ titleModel.get('textBaseline'), titleModel.get('textVerticalAlign')
+ );
var textEl = new graphic.Text({
style: graphic.setTextStyle({}, textStyleModel, {
@@ -184,25 +188,25 @@ echarts.extendComponentView({
layoutRect.x += layoutRect.width / 2;
}
}
- if (!textBaseline) {
- textBaseline = titleModel.get('top') || titleModel.get('bottom');
- if (textBaseline === 'center') {
- textBaseline = 'middle';
+ if (!textVerticalAlign) {
+ textVerticalAlign = titleModel.get('top') || titleModel.get('bottom');
+ if (textVerticalAlign === 'center') {
+ textVerticalAlign = 'middle';
}
- if (textBaseline === 'bottom') {
+ if (textVerticalAlign === 'bottom') {
layoutRect.y += layoutRect.height;
}
- else if (textBaseline === 'middle') {
+ else if (textVerticalAlign === 'middle') {
layoutRect.y += layoutRect.height / 2;
}
- textBaseline = textBaseline || 'top';
+ textVerticalAlign = textVerticalAlign || 'top';
}
group.attr('position', [layoutRect.x, layoutRect.y]);
var alignStyle = {
textAlign: textAlign,
- textVerticalAlign: textBaseline
+ textVerticalAlign: textVerticalAlign
};
textEl.setStyle(alignStyle);
subTextEl.setStyle(alignStyle);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org