* Set tooltip content
(
content: string | HTMLElement | HTMLElement[],
markupStyleCreator: TooltipMarkupStyleCreator,
tooltipModel: Model<TooltipOption>,
borderColor: ZRColor,
arrowPosition: TooltipOption['position']
)
| 76 | * Set tooltip content |
| 77 | */ |
| 78 | setContent( |
| 79 | content: string | HTMLElement | HTMLElement[], |
| 80 | markupStyleCreator: TooltipMarkupStyleCreator, |
| 81 | tooltipModel: Model<TooltipOption>, |
| 82 | borderColor: ZRColor, |
| 83 | arrowPosition: TooltipOption['position'] |
| 84 | ) { |
| 85 | if (zrUtil.isObject(content)) { |
| 86 | throwError(__DEV__ ? 'Passing DOM nodes as content is not supported in richText tooltip!' : ''); |
| 87 | } |
| 88 | if (this.el) { |
| 89 | this._zr.remove(this.el); |
| 90 | } |
| 91 | |
| 92 | const textStyleModel = tooltipModel.getModel('textStyle'); |
| 93 | |
| 94 | this.el = new ZRText({ |
| 95 | style: { |
| 96 | rich: markupStyleCreator.richTextStyles, |
| 97 | text: content as string, |
| 98 | lineHeight: 22, |
| 99 | borderWidth: 1, |
| 100 | borderColor: borderColor as string, |
| 101 | textShadowColor: textStyleModel.get('textShadowColor'), |
| 102 | fill: tooltipModel.get(['textStyle', 'color']), |
| 103 | padding: getPaddingFromTooltipModel(tooltipModel, 'richText'), |
| 104 | verticalAlign: 'top', |
| 105 | align: 'left' |
| 106 | }, |
| 107 | z: tooltipModel.get('z') |
| 108 | }); |
| 109 | zrUtil.each([ |
| 110 | 'backgroundColor', 'borderRadius', 'shadowColor', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY' |
| 111 | ] as const, propName => { |
| 112 | (this.el.style as any)[propName] = tooltipModel.get(propName); |
| 113 | }); |
| 114 | zrUtil.each([ |
| 115 | 'textShadowBlur', 'textShadowOffsetX', 'textShadowOffsetY' |
| 116 | ] as const, propName => { |
| 117 | this.el.style[propName] = textStyleModel.get(propName) || 0; |
| 118 | }); |
| 119 | |
| 120 | this._zr.add(this.el); |
| 121 | |
| 122 | const self = this; |
| 123 | this.el.on('mouseover', function () { |
| 124 | // clear the timeout in hideLater and keep showing tooltip |
| 125 | if (self._enterable) { |
| 126 | clearTimeout(self._hideTimeout); |
| 127 | self._show = true; |
| 128 | } |
| 129 | self._inContent = true; |
| 130 | }); |
| 131 | this.el.on('mouseout', function () { |
| 132 | if (self._enterable) { |
| 133 | if (self._show) { |
| 134 | self.hideLater(self._hideDelay); |
| 135 | } |
nothing calls this directly
no test coverage detected