You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/11/10 08:36:32 UTC
[incubator-echarts] 01/01: fix(label): inheritOpacityshould not
been applied in rich when opacity in top is given.
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch fix-inherit-opacity-in-rich
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
commit 71c8da08e5fa06a4666552a8ae36936f64423c95
Author: pissang <bm...@gmail.com>
AuthorDate: Tue Nov 10 16:36:00 2020 +0800
fix(label): inheritOpacityshould not been applied in rich when opacity in top is given.
And refact inheritOpacity to defaultOpacity.
---
src/chart/bar/BarView.ts | 2 +-
src/chart/bar/PictorialBarView.ts | 2 +-
src/chart/funnel/FunnelView.ts | 2 +-
src/chart/heatmap/HeatmapView.ts | 2 +-
src/chart/helper/Line.ts | 2 +-
src/chart/helper/Symbol.ts | 2 +-
src/chart/pie/PieView.ts | 2 +-
src/chart/radar/RadarView.ts | 2 +-
src/chart/treemap/TreemapView.ts | 2 +-
src/label/labelStyle.ts | 22 ++++++++++++----------
10 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/src/chart/bar/BarView.ts b/src/chart/bar/BarView.ts
index 88dd9fa..6f96daa 100644
--- a/src/chart/bar/BarView.ts
+++ b/src/chart/bar/BarView.ts
@@ -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
}
);
diff --git a/src/chart/bar/PictorialBarView.ts b/src/chart/bar/PictorialBarView.ts
index 1c3da45..13b82c8 100644
--- a/src/chart/bar/PictorialBarView.ts
+++ b/src/chart/bar/PictorialBarView.ts
@@ -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
}
);
diff --git a/src/chart/funnel/FunnelView.ts b/src/chart/funnel/FunnelView.ts
index d165564..63895ad 100644
--- a/src/chart/funnel/FunnelView.ts
+++ b/src/chart/funnel/FunnelView.ts
@@ -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: {
diff --git a/src/chart/heatmap/HeatmapView.ts b/src/chart/heatmap/HeatmapView.ts
index b8209d0..12bc997 100644
--- a/src/chart/heatmap/HeatmapView.ts
+++ b/src/chart/heatmap/HeatmapView.ts
@@ -279,7 +279,7 @@ class HeatmapView extends ChartView {
{
labelFetcher: seriesModel,
labelDataIndex: idx,
- inheritOpacity: style.opacity,
+ defaultOpacity: style.opacity,
defaultText: defaultText
}
);
diff --git a/src/chart/helper/Line.ts b/src/chart/helper/Line.ts
index f0b0c63..93d0fb3 100644
--- a/src/chart/helper/Line.ts
+++ b/src/chart/helper/Line.ts
@@ -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)
diff --git a/src/chart/helper/Symbol.ts b/src/chart/helper/Symbol.ts
index 27e4ebc..cea1c1a 100644
--- a/src/chart/helper/Symbol.ts
+++ b/src/chart/helper/Symbol.ts
@@ -319,7 +319,7 @@ class Symbol extends graphic.Group {
labelDataIndex: idx,
defaultText: getLabelDefaultText,
inheritColor: visualColor as ColorString,
- inheritOpacity: symbolStyle.opacity
+ defaultOpacity: symbolStyle.opacity
}
);
diff --git a/src/chart/pie/PieView.ts b/src/chart/pie/PieView.ts
index bb0a22a..02c03e8 100644
--- a/src/chart/pie/PieView.ts
+++ b/src/chart/pie/PieView.ts
@@ -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)
}
diff --git a/src/chart/radar/RadarView.ts b/src/chart/radar/RadarView.ts
index ce1131e..e87ae5c 100644
--- a/src/chart/radar/RadarView.ts
+++ b/src/chart/radar/RadarView.ts
@@ -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
}
);
});
diff --git a/src/chart/treemap/TreemapView.ts b/src/chart/treemap/TreemapView.ts
index a64bba4..66a3181 100644
--- a/src/chart/treemap/TreemapView.ts
+++ b/src/chart/treemap/TreemapView.ts
@@ -978,7 +978,7 @@ function renderNode(
{
defaultText: isShow ? text : null,
inheritColor: visualColor,
- inheritOpacity: visualOpacity,
+ defaultOpacity: visualOpacity,
labelFetcher: seriesModel,
labelDataIndex: thisNode.dataIndex
}
diff --git a/src/label/labelStyle.ts b/src/label/labelStyle.ts
index 2c8f3e8..b2c6d1a 100644
--- a/src/label/labelStyle.ts
+++ b/src/label/labelStyle.ts
@@ -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;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org