提交 1898edbc 编写于 作者: S sushuang

Support textVerticalAlign as the alias as textBaseline in title component.

上级 5a3c7d00
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册