(
content: string | HTMLElement | HTMLElement[],
markers: unknown,
tooltipModel: Model<TooltipOption>,
borderColor?: ZRColor,
arrowPosition?: TooltipOption['position']
)
| 431 | } |
| 432 | |
| 433 | setContent( |
| 434 | content: string | HTMLElement | HTMLElement[], |
| 435 | markers: unknown, |
| 436 | tooltipModel: Model<TooltipOption>, |
| 437 | borderColor?: ZRColor, |
| 438 | arrowPosition?: TooltipOption['position'] |
| 439 | ) { |
| 440 | const el = this.el; |
| 441 | |
| 442 | if (content == null) { |
| 443 | el.innerHTML = ''; |
| 444 | return; |
| 445 | } |
| 446 | |
| 447 | let arrow = ''; |
| 448 | if (isString(arrowPosition) && tooltipModel.get('trigger') === 'item' |
| 449 | && !shouldTooltipConfine(tooltipModel)) { |
| 450 | arrow = assembleArrow(tooltipModel, borderColor, arrowPosition); |
| 451 | } |
| 452 | if (isString(content)) { |
| 453 | el.innerHTML = content + arrow; |
| 454 | } |
| 455 | else if (content) { |
| 456 | // Clear previous |
| 457 | el.innerHTML = ''; |
| 458 | if (!isArray(content)) { |
| 459 | content = [content]; |
| 460 | } |
| 461 | for (let i = 0; i < content.length; i++) { |
| 462 | if (isDom(content[i]) && content[i].parentNode !== el) { |
| 463 | el.appendChild(content[i]); |
| 464 | } |
| 465 | } |
| 466 | // no arrow if empty |
| 467 | if (arrow && el.childNodes.length) { |
| 468 | // no need to create a new parent element, but it's not supported by IE 10 and older. |
| 469 | // const arrowEl = document.createRange().createContextualFragment(arrow); |
| 470 | const arrowEl = document.createElement('div'); |
| 471 | arrowEl.innerHTML = arrow; |
| 472 | el.appendChild(arrowEl); |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | setEnterable(enterable: boolean) { |
| 478 | this._enterable = enterable; |
no test coverage detected