Skip to content

Commit a24e8aa

Browse files
authored
Merge pull request #20961 from apache/fix/visualMap-textStyle
fix(visualMap): fix some text style can't work on visualMap
2 parents ef926fa + 7d76132 commit a24e8aa

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

src/component/visualMap/ContinuousView.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,10 @@ class ContinuousView extends VisualMapView {
191191
style: createTextStyle(textStyleModel, {
192192
x: position[0],
193193
y: position[1],
194-
verticalAlign: orient === 'horizontal' ? 'middle' : align as TextVerticalAlign,
195-
align: orient === 'horizontal' ? align as TextAlign : 'center',
194+
verticalAlign: textStyleModel.get('verticalAlign')
195+
|| (orient === 'horizontal' ? 'middle' : align as TextVerticalAlign),
196+
align: textStyleModel.get('align')
197+
|| (orient === 'horizontal' ? align as TextAlign : 'center'),
196198
text
197199
})
198200
}));

src/component/visualMap/PiecewiseView.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ class PiecewiseVisualMapView extends VisualMapView {
4444
const visualMapModel = this.visualMapModel;
4545
const textGap = visualMapModel.get('textGap');
4646
const textStyleModel = visualMapModel.textStyleModel;
47-
const textFont = textStyleModel.getFont();
48-
const textFill = textStyleModel.getTextColor();
4947
const itemAlign = this._getItemAlign();
5048
const itemSize = visualMapModel.itemSize;
5149
const viewData = this._getViewData();
@@ -74,17 +72,19 @@ class PiecewiseVisualMapView extends VisualMapView {
7472

7573
if (showLabel) {
7674
const visualState = this.visualMapModel.getValueState(representValue);
75+
const align = textStyleModel.get('align') || itemAlign as TextAlign;
7776
itemGroup.add(new graphic.Text({
78-
style: {
79-
x: itemAlign === 'right' ? -textGap : itemSize[0] + textGap,
77+
style: createTextStyle(textStyleModel, {
78+
x: align === 'right' ? -textGap : itemSize[0] + textGap,
8079
y: itemSize[1] / 2,
8180
text: piece.text,
82-
verticalAlign: 'middle',
83-
align: itemAlign as TextAlign,
84-
font: textFont,
85-
fill: textFill,
86-
opacity: visualState === 'outOfRange' ? 0.5 : 1,
87-
},
81+
verticalAlign: textStyleModel.get('verticalAlign') || 'middle',
82+
align,
83+
opacity: zrUtil.retrieve2(
84+
textStyleModel.get('opacity'),
85+
visualState === 'outOfRange' ? 0.5 : 1
86+
),
87+
}),
8888
silent
8989
}));
9090
}

test/visualMap-pieces.html

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)