Skip to content

Commit

Permalink
fix(visualmap): add textShadowColor, make text shadow work on visualM…
Browse files Browse the repository at this point in the history
…ap. close apache#14440
  • Loading branch information
fuchunhui committed Mar 14, 2022
1 parent 6a42c39 commit 3d8e255
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 218 deletions.
4 changes: 3 additions & 1 deletion src/component/visualMap/ContinuousView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class ContinuousView extends VisualMapView {
);
const orient = this._orient;
const textStyleModel = this.visualMapModel.textStyleModel;
const textShadow = textStyleModel.getTextShadow();

this.group.add(new graphic.Text({
style: {
Expand All @@ -191,7 +192,8 @@ class ContinuousView extends VisualMapView {
align: orient === 'horizontal' ? align as TextAlign : 'center',
text: text,
font: textStyleModel.getFont(),
fill: textStyleModel.getTextColor()
fill: textStyleModel.getTextColor(),
...textShadow
}
}));
}
Expand Down
6 changes: 3 additions & 3 deletions src/component/visualMap/PiecewiseView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ class PiecewiseVisualMapView extends VisualMapView {
this.renderBackground(thisGroup);

this.positionGroup(thisGroup);


}

private _enableHoverLink(itemGroup: graphic.Group, pieceIndex: number) {
Expand Down Expand Up @@ -155,6 +153,7 @@ class PiecewiseVisualMapView extends VisualMapView {

const itemGroup = new graphic.Group();
const textStyleModel = this.visualMapModel.textStyleModel;
const textShadow = textStyleModel.getTextShadow();

itemGroup.add(new graphic.Text({
style: {
Expand All @@ -164,7 +163,8 @@ class PiecewiseVisualMapView extends VisualMapView {
align: showLabel ? (itemAlign as TextAlign) : 'center',
text: text,
font: textStyleModel.getFont(),
fill: textStyleModel.getTextColor()
fill: textStyleModel.getTextColor(),
...textShadow
}
}));

Expand Down
11 changes: 11 additions & 0 deletions src/model/mixin/textStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const textStyleParams = [
'fontStyle', 'fontWeight', 'fontSize', 'fontFamily', 'padding',
'lineHeight', 'rich', 'width', 'height', 'overflow'
] as const;
type LabelTextShadowOption = Pick<LabelOption,
'textShadowBlur' | 'textShadowColor' | 'textShadowOffsetX' | 'textShadowOffsetY'>;

// TODO Performance improvement?
const tmpText = new ZRText();
Expand Down Expand Up @@ -77,6 +79,15 @@ class TextStyleMixin {
tmpText.update();
return tmpText.getBoundingRect();
}

getTextShadow(this: Model<LabelTextShadowOption>) {
return {
textShadowBlur: this.getShallow('textShadowBlur'),
textShadowColor: this.getShallow('textShadowColor'),
textShadowOffsetX: this.getShallow('textShadowOffsetX'),
textShadowOffsetY: this.getShallow('textShadowOffsetY')
};
}
};

export default TextStyleMixin;
171 changes: 64 additions & 107 deletions test/visualMap-continuous.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3d8e255

Please sign in to comment.