Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: fix the order of title in mark tooltip when dimension tooltip has no title, fix #3991\n\n",
"type": "none",
"packageName": "@visactor/vchart"
}
],
"packageName": "@visactor/vchart",
"email": "dingling112@gmail.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,21 @@ export class DomTooltipHandler extends BaseTooltipHandler {
const rowStyle = this._domStyle.row;
const chilren = [...(this._rootDom.children as any)] as HTMLElement[];
let titleDom = chilren.find(child => child.className.includes(TOOLTIP_TITLE_CLASS_NAME));
let contentDom = chilren.find(child => child.className.includes(TOOLTIP_CONTENT_BOX_CLASS_NAME));

if (!titleDom && title.visible !== false) {
titleDom = document.createElement('h2');
const span = document.createElement('span');
titleDom.appendChild(span);

titleDom.classList.add(TOOLTIP_TITLE_CLASS_NAME);
this._rootDom.appendChild(titleDom);

// 将 titleDom 插入到 this._rootDom 中作为第一个节点
if (this._rootDom.firstChild) {
this._rootDom.insertBefore(titleDom, this._rootDom.firstChild);
} else {
this._rootDom.appendChild(titleDom);
}
}

if (titleDom && title.visible !== false) {
Expand All @@ -223,7 +230,6 @@ export class DomTooltipHandler extends BaseTooltipHandler {
titleDom.parentNode.removeChild(titleDom);
}

let contentDom = chilren.find(child => child.className.includes(TOOLTIP_CONTENT_BOX_CLASS_NAME));
const columns = ['shape', 'key', 'value'];

if (!contentDom && hasContent) {
Expand Down
Loading