未验证 提交 87ccbdb9 编写于 作者: Y Yi Shen 提交者: GitHub

Merge pull request #13591 from apache/fix-inherit-opacity-in-rich

fix(label): inheritOpacity should not been applied in rich when opacity in top is given.
......@@ -855,7 +855,7 @@ function updateStyle(
labelDataIndex: dataIndex,
defaultText: getDefaultLabel(seriesModel.getData(), dataIndex),
inheritColor: style.fill as ColorString,
inheritOpacity: style.opacity,
defaultOpacity: style.opacity,
defaultOutsidePosition: labelPositionOutside
}
);
......
......@@ -930,7 +930,7 @@ function updateCommon(
labelDataIndex: dataIndex,
defaultText: getDefaultLabel(opt.seriesModel.getData(), dataIndex),
inheritColor: symbolMeta.style.fill as ColorString,
inheritOpacity: symbolMeta.style.opacity,
defaultOpacity: symbolMeta.style.opacity,
defaultOutsidePosition: barPositionOutside
}
);
......
......@@ -112,7 +112,7 @@ class FunnelPiece extends graphic.Polygon {
{
labelFetcher: data.hostModel as FunnelSeriesModel,
labelDataIndex: idx,
inheritOpacity: style.opacity,
defaultOpacity: style.opacity,
defaultText: data.getName(idx)
},
{ normal: {
......
......@@ -279,7 +279,7 @@ class HeatmapView extends ChartView {
{
labelFetcher: seriesModel,
labelDataIndex: idx,
inheritOpacity: style.opacity,
defaultOpacity: style.opacity,
defaultText: defaultText
}
);
......
......@@ -256,7 +256,7 @@ class Line extends graphic.Group {
}
},
inheritColor: visualColor as ColorString || '#000',
inheritOpacity: lineStyle.opacity,
defaultOpacity: lineStyle.opacity,
defaultText: (rawVal == null
? lineData.getName(idx)
: isFinite(rawVal)
......
......@@ -319,7 +319,7 @@ class Symbol extends graphic.Group {
labelDataIndex: idx,
defaultText: getLabelDefaultText,
inheritColor: visualColor as ColorString,
inheritOpacity: symbolStyle.opacity
defaultOpacity: symbolStyle.opacity
}
);
......
......@@ -165,7 +165,7 @@ class PiePiece extends graphic.Sector {
labelFetcher: data.hostModel as PieSeriesModel,
labelDataIndex: idx,
inheritColor: visualColor,
inheritOpacity: visualOpacity,
defaultOpacity: visualOpacity,
defaultText: seriesModel.getFormattedLabel(idx, 'normal')
|| data.getName(idx)
}
......
......@@ -256,7 +256,7 @@ class RadarView extends ChartView {
labelDimIndex: symbolPath.__dimIdx,
defaultText: defaultText as string,
inheritColor: color as ColorString,
inheritOpacity: itemStyle.opacity
defaultOpacity: itemStyle.opacity
}
);
});
......
......@@ -978,7 +978,7 @@ function renderNode(
{
defaultText: isShow ? text : null,
inheritColor: visualColor,
inheritOpacity: visualOpacity,
defaultOpacity: visualOpacity,
labelFetcher: seriesModel,
labelDataIndex: thisNode.dataIndex
}
......
......@@ -53,10 +53,9 @@ type TextCommonParams = {
inheritColor?: ColorString
/**
* Specify a opacity when opacity is 'inherit',
* If inheritColor specified, it is used as default textFill.
* Specify a opacity when opacity is not given.
*/
inheritOpacity?: number
defaultOpacity?: number
defaultOutsidePosition?: LabelOption['position']
......@@ -362,7 +361,7 @@ export function createTextConfig(
function setTextStyleCommon(
textStyle: TextStyleProps,
textStyleModel: Model,
opt?: Pick<TextCommonParams, 'inheritColor' | 'inheritOpacity' | 'disableBox'>,
opt?: Pick<TextCommonParams, 'inheritColor' | 'defaultOpacity' | 'disableBox'>,
isNotNormal?: boolean,
isAttached?: boolean
) {
......@@ -397,7 +396,9 @@ function setTextStyleCommon(
// the default color `'blue'` will not be adopted if no color declared in `rich`.
// That might confuses users. So probably we should put `textStyleModel` as the
// root ancestor of the `richTextStyle`. But that would be a break change.
setTokenTextStyle(richResult[name] = {}, richTextStyle, globalTextStyle, opt, isNotNormal, isAttached);
setTokenTextStyle(
richResult[name] = {}, richTextStyle, globalTextStyle, opt, isNotNormal, isAttached, false, true
);
}
}
}
......@@ -412,7 +413,7 @@ function setTextStyleCommon(
if (margin != null) {
textStyle.margin = margin;
}
setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isNotNormal, isAttached, true);
setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isNotNormal, isAttached, true, false);
}
// Consider case:
// {
......@@ -463,10 +464,11 @@ function setTokenTextStyle(
textStyle: TextStyleProps['rich'][string],
textStyleModel: Model<LabelOption>,
globalTextStyle: LabelOption,
opt?: Pick<TextCommonParams, 'inheritColor' | 'inheritOpacity' | 'disableBox'>,
opt?: Pick<TextCommonParams, 'inheritColor' | 'defaultOpacity' | 'disableBox'>,
isNotNormal?: boolean,
isAttached?: boolean,
isBlock?: boolean
isBlock?: boolean,
inRich?: boolean
) {
// In merge mode, default value should not be given.
globalTextStyle = !isNotNormal && globalTextStyle || EMPTY_OBJ;
......@@ -527,8 +529,8 @@ function setTokenTextStyle(
textStyle.lineDashOffset = textBorderDashOffset;
}
if (!isNotNormal && (opacity == null)) {
opacity = opt && opt.inheritOpacity;
if (!isNotNormal && (opacity == null) && !inRich) {
opacity = opt && opt.defaultOpacity;
}
if (opacity != null) {
textStyle.opacity = opacity;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册