diff --git a/src/component/tooltip/TooltipRichContent.ts b/src/component/tooltip/TooltipRichContent.ts index d8f038dcbf..19925f6196 100644 --- a/src/component/tooltip/TooltipRichContent.ts +++ b/src/component/tooltip/TooltipRichContent.ts @@ -111,11 +111,7 @@ class TooltipRichContent { ] as const, propName => { (this.el.style as any)[propName] = tooltipModel.get(propName); }); - zrUtil.each([ - 'textShadowBlur', 'textShadowOffsetX', 'textShadowOffsetY' - ] as const, propName => { - this.el.style[propName] = textStyleModel.get(propName) || 0; - }); + applyRichTextStyle(this.el.style, textStyleModel); this._zr.add(this.el); @@ -217,6 +213,30 @@ class TooltipRichContent { } } +function applyRichTextStyle( + style: TextStyleProps, + textStyleModel: Model +) { + zrUtil.each([ + 'fontStyle', 'fontWeight', 'fontSize', 'fontFamily', 'lineHeight', + 'textShadowBlur', 'textShadowOffsetX', 'textShadowOffsetY' + ] as const, propName => { + const val = textStyleModel.get(propName); + if (val != null) { + (style as any)[propName] = val; + } + }); + + const textBorderColor = textStyleModel.get('textBorderColor'); + if (textBorderColor != null) { + style.stroke = textBorderColor; + } + const textBorderWidth = textStyleModel.get('textBorderWidth'); + if (textBorderWidth != null) { + style.lineWidth = textBorderWidth; + } +} + function mathMaxWith0(val: number): number { return Math.max(0, val); } diff --git a/test/tooltip-textStyle.html b/test/tooltip-textStyle.html index ce4ffecfd8..a1e3e8dd5c 100644 --- a/test/tooltip-textStyle.html +++ b/test/tooltip-textStyle.html @@ -118,6 +118,11 @@ tooltip: { textStyle: { fontSize: 20, + fontStyle: 'italic', + fontWeight: 'bold', + fontFamily: 'monospace', + textBorderColor: 'blue', + textBorderWidth: 1, textShadowColor: 'red', textShadowBlur: 10, textShadowOffsetX: 10, @@ -137,7 +142,7 @@ title: [ 'trigger: **"item"**', 'renderMode: **"richText"**', - 'It should have red text shadow and font size being 20px' + 'It should use monospace bold italic text, blue text border, red text shadow, and 20px font size' ], option: option // height: 300,