提交 8fea2846 编写于 作者: P pissang

fix(label): support legacy style color: 'auto' for color: 'inherit' usage.

Not breaking the exists code.
上级 41ba1573
......@@ -264,7 +264,9 @@ class GaugeView extends ChartView {
y: unitY * (r - splitLineLen - distance) + cy,
verticalAlign: unitY < -0.4 ? 'top' : (unitY > 0.4 ? 'bottom' : 'middle'),
align: unitX < -0.4 ? 'left' : (unitX > 0.4 ? 'right' : 'center')
}, {inheritColor: autoColor}),
}, {
inheritColor: autoColor
}),
silent: true
}));
}
......
......@@ -16,6 +16,8 @@ import {
import GlobalModel from '../model/Global';
import { isFunction, retrieve2, extend, keys, trim } from 'zrender/src/core/util';
import { SPECIAL_STATES, DISPLAY_STATES } from '../util/states';
import { __DEV__ } from '../config';
import { deprecateReplaceLog } from '../util/log';
type TextCommonParams = {
/**
......@@ -30,6 +32,11 @@ type TextCommonParams = {
defaultOutsidePosition?: LabelOption['position']
/**
* If support legacy 'auto' for 'inherit' usage.
*/
// supportLegacyAuto?: boolean
textStyle?: ZRStyleProps
};
const EMPTY_OBJ = {};
......@@ -406,7 +413,12 @@ function setTokenTextStyle(
const inheritColor = opt && opt.inheritColor;
let fillColor = textStyleModel.getShallow('color');
let strokeColor = textStyleModel.getShallow('textBorderColor');
if (fillColor === 'inherit') {
if (fillColor === 'inherit' || fillColor === 'auto') {
if (__DEV__) {
if (fillColor === 'auto') {
deprecateReplaceLog('color: \'auto\'', 'color: \'inherit\'');
}
}
if (inheritColor) {
fillColor = inheritColor;
}
......@@ -414,12 +426,17 @@ function setTokenTextStyle(
fillColor = null;
}
}
if (strokeColor === 'inherit' && inheritColor) {
if (strokeColor === 'inherit' || (strokeColor === 'auto')) {
if (__DEV__) {
if (strokeColor === 'auto') {
deprecateReplaceLog('color: \'auto\'', 'color: \'inherit\'');
}
}
if (inheritColor) {
strokeColor = inheritColor;
}
else {
strokeColor = inheritColor;
strokeColor = null;
}
}
fillColor = fillColor || globalTextStyle.color;
......@@ -465,12 +482,6 @@ function setTokenTextStyle(
}
}
if (!isBlock || !opt.disableBox) {
if (textStyle.backgroundColor === 'auto' && inheritColor) {
textStyle.backgroundColor = inheritColor;
}
if (textStyle.borderColor === 'auto' && inheritColor) {
textStyle.borderColor = inheritColor;
}
for (let i = 0; i < TEXT_PROPS_BOX.length; i++) {
const key = TEXT_PROPS_BOX[i];
const val = textStyleModel.getShallow(key);
......@@ -478,6 +489,23 @@ function setTokenTextStyle(
(textStyle as any)[key] = val;
}
}
if ((textStyle.backgroundColor === 'auto' || textStyle.backgroundColor === 'inherit') && inheritColor) {
if (__DEV__) {
if (textStyle.backgroundColor === 'auto') {
deprecateReplaceLog('backgroundColor: \'auto\'', 'backgroundColor: \'inherit\'');
}
}
textStyle.backgroundColor = inheritColor;
}
if ((textStyle.borderColor === 'auto' || textStyle.borderColor === 'inherit') && inheritColor) {
if (__DEV__) {
if (textStyle.borderColor === 'auto') {
deprecateReplaceLog('borderColor: \'auto\'', 'borderColor: \'inherit\'');
}
}
textStyle.borderColor = inheritColor;
}
}
}
export function getFont(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册