提交 1d72599c 编写于 作者: L lang

Global text color

上级 e3b525e8
......@@ -178,7 +178,7 @@ define(function (require) {
|| labelPosition === 'inner' || labelPosition === 'center';
labelText.setStyle({
// Default use item visual color
fill: textStyleModel.get('color')
fill: textStyleModel.getTextColor()
|| isLabelInside ? '#fff' : visualColor,
text: seriesModel.getFormattedLabel(idx, 'normal')
|| data.getName(idx),
......
......@@ -204,7 +204,7 @@ define(function (require) {
text: label,
x: unitX * (r - splitLineLen - 5) + cx,
y: unitY * (r - splitLineLen - 5) + cy,
fill: textStyleModel.get('color'),
fill: textStyleModel.getTextColor(),
textFont: textStyleModel.getFont(),
textBaseline: unitY < -0.4 ? 'top' : (unitY > 0.4 ? 'bottom' : 'middle'),
textAlign: unitX < -0.4 ? 'left' : (unitX > 0.4 ? 'right' : 'center')
......@@ -348,7 +348,7 @@ define(function (require) {
y: y,
// FIXME First data name ?
text: seriesModel.getData().getName(0),
fill: textStyleModel.get('color'),
fill: textStyleModel.getTextColor(),
textFont: textStyleModel.getFont(),
textAlign: 'center',
textBaseline: 'middle'
......@@ -385,7 +385,7 @@ define(function (require) {
value, detailModel.get('formatter')
),
fill: detailModel.get('backgroundColor'),
textFill: textStyleModel.get('color'),
textFill: textStyleModel.getTextColor(),
textFont: textStyleModel.getFont()
}
});
......
......@@ -243,14 +243,14 @@ define(function (require) {
? seriesModel.getFormattedLabel(idx, 'normal') || defaultText
: '',
textFont: textStyleModel.getFont(),
fill: textStyleModel.get('color') || lineData.getItemVisual(idx, 'color')
fill: textStyleModel.getTextColor() || lineData.getItemVisual(idx, 'color')
});
label.hoverStyle = {
text: labelHoverModel.get('show')
? seriesModel.getFormattedLabel(idx, 'emphasis') || defaultText
: '',
textFont: textStyleModel.getFont(),
fill: textStyleHoverModel.get('color')
fill: textStyleHoverModel.getTextColor()
};
label.__textAlign = textStyleModel.get('align');
label.__textBaseline = textStyleModel.get('baseline');
......
......@@ -71,7 +71,7 @@ define(function (require) {
var showLabel = labelModel.get('show');
var labelText = data.getName(idx);
var labelColor = textStyleModel.get('color');
var labelColor = textStyleModel.getTextColor();
var labelFont = textStyleModel.getFont();
var circle = new graphic.Circle({
......
......@@ -98,7 +98,7 @@ define(function (require) {
var position = labelModel.get('position');
var isLabelInside = position === 'inside' || position === 'inner';
return {
fill: textStyleModel.get('color')
fill: textStyleModel.getTextColor()
|| isLabelInside ? '#fff' : data.getItemVisual(idx, 'color'),
textFont: textStyleModel.getFont(),
text: data.hostModel.getFormattedLabel(idx, state)
......
......@@ -92,7 +92,7 @@ define(function (require) {
// Use empty string to hide the label
: '',
textFont: textStyleModel.getFont(),
textFill: textStyleModel.get('color'),
textFill: textStyleModel.getTextColor(),
textPosition: labelModel.get('position')
}
});
......@@ -111,7 +111,7 @@ define(function (require) {
? seriesModel.getFormattedLabel(node.dataIndex, 'emphasis') || node.id
: '',
textFont: textStyleHoverModel.getFont(),
textFill: textStyleHoverModel.get('color'),
textFill: textStyleHoverModel.getTextColor(),
textPosition: labelHoverModel.get('position')
}
));
......
......@@ -123,7 +123,7 @@
{
lineJoin: 'bevel',
text: text,
textFill: textStyleModel.get('color'),
textFill: textStyleModel.getTextColor(),
textAlign: 'left',
textFont: textStyleModel.getFont()
}
......
......@@ -323,7 +323,7 @@
fill: thisNode.getVisual('color', true),
text: text,
textPosition: labelModel.get('position'),
textFill: textStyleModel.get('color'),
textFill: textStyleModel.getTextColor(),
textAlign: textStyleModel.get('align'),
textBaseline: textStyleModel.get('baseline'),
textFont: textStyleModel.getFont()
......
......@@ -125,7 +125,7 @@ define(function (require) {
style: {
x: p[0],
y: p[1],
fill: textStyleModel.get('color'),
fill: textStyleModel.getTextColor(),
text: labels[i],
textAlign: labelTextAlign,
textBaseline: labelTextBaseline,
......
......@@ -233,7 +233,7 @@ define(function (require) {
textAlign: labelLayout.textAlign,
textBaseline: labelLayout.textBaseline,
textFont: itemTextStyleModel.getFont(),
fill: itemTextStyleModel.get('color')
fill: itemTextStyleModel.getTextColor()
},
position: pos,
rotation: labelLayout.rotation,
......@@ -289,7 +289,7 @@ define(function (require) {
style: {
text: name,
textFont: textStyleModel.getFont(),
fill: textStyleModel.get('color')
fill: textStyleModel.getTextColor()
|| axisModel.get('axisLine.lineStyle.color'),
textAlign: labelLayout.textAlign,
textBaseline: labelLayout.textBaseline
......
......@@ -139,7 +139,7 @@ define(function(require) {
textAlign: orient === 'horizontal' ? align : 'center',
text: text,
textFont: textStyleModel.getFont(),
fill: textStyleModel.get('color')
fill: textStyleModel.getTextColor()
}
}));
},
......@@ -220,7 +220,7 @@ define(function(require) {
x: 0, y: 0, text: '',
textBaseline: 'middle',
textFont: textStyleModel.getFont(),
fill: textStyleModel.get('color')
fill: textStyleModel.getTextColor()
}
});
......
......@@ -25,7 +25,7 @@ define(function(require) {
var textGap = dataRangeModel.get('textGap');
var textStyleModel = dataRangeModel.textStyleModel;
var textFont = textStyleModel.getFont();
var textFill = textStyleModel.get('color');
var textFill = textStyleModel.getTextColor();
var itemAlign = this.getItemAlignByOrient('horizontal', ecWidth);
var itemSize = dataRangeModel.itemSize;
......@@ -88,7 +88,7 @@ define(function(require) {
textAlign: 'center',
text: text,
textFont: textStyleModel.getFont(),
fill: textStyleModel.get('color')
fill: textStyleModel.getTextColor()
}
}));
......
......@@ -396,7 +396,7 @@ define(function (require) {
x: 0, y: 0, text: '',
textBaseline: 'middle',
textAlign: 'center',
fill: textStyleModel.get('color'),
fill: textStyleModel.getTextColor(),
textFont: textStyleModel.getFont()
}
}));
......
......@@ -179,14 +179,14 @@ define(function (require) {
var text = new graphic.Text({
style: {
text: showLabel ? (formattedStr || region.name) : '',
fill: textStyleModel.get('color'),
fill: textStyleModel.getTextColor(),
textFont: textStyleModel.getFont(),
textAlign: 'center',
textBaseline: 'middle'
},
hoverStyle: {
text: hoverShowLabel ? (hoverFormattedStr || region.name) : '',
fill: hoverTextStyleModel.get('color'),
fill: hoverTextStyleModel.getTextColor(),
textFont: hoverTextStyleModel.getFont()
},
position: region.center.slice(),
......
......@@ -236,7 +236,7 @@ define(function (require) {
text: name,
x: textX,
y: itemHeight / 2,
fill: textStyleModel.get('color'),
fill: textStyleModel.getTextColor(),
textFont: textStyleModel.getFont(),
textAlign: textAlign,
textBaseline: 'middle'
......
......@@ -94,7 +94,7 @@ define(function(require) {
style: {
text: titleModel.get('text'),
textFont: textStyleModel.getFont(),
fill: textStyleModel.get('color'),
fill: textStyleModel.getTextColor(),
textBaseline: 'top'
}
});
......@@ -106,7 +106,7 @@ define(function(require) {
style: {
text: subText,
textFont: subtextStyleModel.getFont(),
fill: subtextStyleModel.get('color'),
fill: subtextStyleModel.getTextColor(),
y: textRect.height + titleModel.get('itemGap'),
textBaseline: 'top'
}
......
......@@ -636,7 +636,7 @@ define(function (require) {
});
text.setStyle({
fill: textStyleModel.get('color') || crossStyleModel.get('color'),
fill: textStyleModel.getTextColor() || crossStyleModel.get('color'),
textFont: textStyleModel.getFont(),
text: value.join(', '),
x: point[0] + 5,
......
......@@ -37,7 +37,7 @@ define(function (require) {
var cssText = [];
var fontSize = textStyleModel.get('fontSize');
var color = textStyleModel.get('color');
var color = textStyleModel.getTextColor();
color && cssText.push('color:' + color);
......
......@@ -7,6 +7,20 @@ define(function (require) {
}
return {
/**
* Get color property or get color from option.textStyle.color
* @return {string}
*/
getTextColor: function () {
var ecModel = this.ecModel;
return this.getShallow('color')
|| (ecModel && ecModel.get('textStyle.color'));
},
/**
* Create font string from fontStyle, fontWeight, fontSize, fontFamily
* @return {string}
*/
getFont: function () {
var ecModel = this.ecModel;
var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
......
......@@ -314,7 +314,7 @@ define(function(require) {
textDistance: labelModel.getShallow('distance') || 5,
textFont: textStyleModel.getFont(),
textPosition: labelPosition,
textFill: textStyleModel.get('color') || labelColor
textFill: textStyleModel.getTextColor() || labelColor
});
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册