From 47402d7448137969c643047294cdea5f79df51cf Mon Sep 17 00:00:00 2001 From: xile611 Date: Fri, 27 Dec 2024 15:42:46 +0800 Subject: [PATCH 1/7] fix: fix style of dom tooltip when tooltip has customized child, fix #3615 --- .../components/tooltip-handler/dom-tooltip-handler.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts b/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts index a76cd42c9a..12f5a289f1 100644 --- a/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts +++ b/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts @@ -299,9 +299,11 @@ export class DomTooltipHandler extends BaseTooltipHandler { protected _updateDomStyle(sizeKey: 'width' | 'height' = 'width') { const rootDom = this._rootDom; - const contentDom = rootDom.children[rootDom.children.length - 1]; + const contentDom = [...(rootDom.children as any)].find(child => + child.className.includes(TOOLTIP_CONTENT_BOX_CLASS_NAME) + ); - if (contentDom.className.includes(TOOLTIP_CONTENT_BOX_CLASS_NAME)) { + if (contentDom) { const tooltipSpec = this._component.getSpec() as ITooltipSpec; const contentStyle: Partial = {}; From 5bdd59581455d9bc23a4ee4f823fb157cf8e41d7 Mon Sep 17 00:00:00 2001 From: xile611 Date: Fri, 27 Dec 2024 15:43:40 +0800 Subject: [PATCH 2/7] docs: update changlog of rush --- ...-when-has-customized-content_2024-12-27-07-43.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 common/changes/@visactor/vchart/fix-dom-style-when-has-customized-content_2024-12-27-07-43.json diff --git a/common/changes/@visactor/vchart/fix-dom-style-when-has-customized-content_2024-12-27-07-43.json b/common/changes/@visactor/vchart/fix-dom-style-when-has-customized-content_2024-12-27-07-43.json new file mode 100644 index 0000000000..6aefdb8740 --- /dev/null +++ b/common/changes/@visactor/vchart/fix-dom-style-when-has-customized-content_2024-12-27-07-43.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "fix: fix style of dom tooltip when tooltip has customized child, fix #3615\n\n", + "type": "none", + "packageName": "@visactor/vchart" + } + ], + "packageName": "@visactor/vchart", + "email": "dingling112@gmail.com" +} \ No newline at end of file From 199ced0aafa9aa532c3f6d21024ed5eb17a56db4 Mon Sep 17 00:00:00 2001 From: xile611 Date: Fri, 27 Dec 2024 15:55:53 +0800 Subject: [PATCH 3/7] fix: fix error update of dom tooltip when update theme, fix #3619 --- .../components/tooltip-handler/dom-tooltip-handler.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts b/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts index 12f5a289f1..0d76e029fb 100644 --- a/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts +++ b/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts @@ -371,6 +371,14 @@ export class DomTooltipHandler extends BaseTooltipHandler { reInit() { super.reInit(); this._initStyle(); + if (this._rootDom) { + setStyleToDom(this._rootDom, this._domStyle.panel); + } + + if (this.getVisibility()) { + this._updateDomStringByCol(this._tooltipActual); + this._updateDomStyle('height'); + } } protected _updatePosition({ x, y }: ITooltipPositionActual) { From d7ee554ed300bb540b42f6ab7b9f98e3424c94b2 Mon Sep 17 00:00:00 2001 From: xile611 Date: Fri, 27 Dec 2024 15:57:46 +0800 Subject: [PATCH 4/7] docs: update changlog of rush --- ...-when-has-customized-content_2024-12-27-07-57.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 common/changes/@visactor/vchart/fix-dom-style-when-has-customized-content_2024-12-27-07-57.json diff --git a/common/changes/@visactor/vchart/fix-dom-style-when-has-customized-content_2024-12-27-07-57.json b/common/changes/@visactor/vchart/fix-dom-style-when-has-customized-content_2024-12-27-07-57.json new file mode 100644 index 0000000000..f289527b10 --- /dev/null +++ b/common/changes/@visactor/vchart/fix-dom-style-when-has-customized-content_2024-12-27-07-57.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "fix: fix error update of dom tooltip when update theme, fix #3619\n\n", + "type": "none", + "packageName": "@visactor/vchart" + } + ], + "packageName": "@visactor/vchart", + "email": "dingling112@gmail.com" +} \ No newline at end of file From cae602350360dfa19167db063f6f60d47833339c Mon Sep 17 00:00:00 2001 From: xile611 Date: Fri, 3 Jan 2025 17:45:14 +0800 Subject: [PATCH 5/7] fix: fix position of html tooltip when confine is false, fix #3632 --- .../vchart/src/plugin/components/tooltip-handler/base.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/vchart/src/plugin/components/tooltip-handler/base.ts b/packages/vchart/src/plugin/components/tooltip-handler/base.ts index e75ca375d0..75f561afcc 100644 --- a/packages/vchart/src/plugin/components/tooltip-handler/base.ts +++ b/packages/vchart/src/plugin/components/tooltip-handler/base.ts @@ -395,9 +395,10 @@ export abstract class BaseTooltipHandler extends BasePlugin implements ITooltipH /* 三、确保tooltip在视区内 */ const containerDimSize = dim === 'x' ? containerSize.width : containerSize.height; - const leftOrTop = - -(tooltipParentElementRect[dim] - (chartElementRect?.[dim] ?? 0) / chartElementScale) / - tooltipParentElementScale; + const leftOrTop = tooltipSpec.confine + ? -(tooltipParentElementRect[dim] - (chartElementRect?.[dim] ?? 0) / chartElementScale) / + tooltipParentElementScale + : -tooltipParentElementRect[dim] / tooltipParentElementScale; const rightOrBottom = containerDimSize / tooltipParentElementScale + leftOrTop - boxSize; // 处理左右 From 991167d31e3b3e19fca57c3dd5e1dad4fc32dac7 Mon Sep 17 00:00:00 2001 From: xile611 Date: Fri, 3 Jan 2025 17:47:14 +0800 Subject: [PATCH 6/7] docs: update changlog of rush --- ...-when-has-customized-content_2025-01-03-09-47.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 common/changes/@visactor/vchart/fix-dom-style-when-has-customized-content_2025-01-03-09-47.json diff --git a/common/changes/@visactor/vchart/fix-dom-style-when-has-customized-content_2025-01-03-09-47.json b/common/changes/@visactor/vchart/fix-dom-style-when-has-customized-content_2025-01-03-09-47.json new file mode 100644 index 0000000000..b43e2b45a9 --- /dev/null +++ b/common/changes/@visactor/vchart/fix-dom-style-when-has-customized-content_2025-01-03-09-47.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "fix: fix position of html tooltip when confine is false, fix #3632\n\n", + "type": "none", + "packageName": "@visactor/vchart" + } + ], + "packageName": "@visactor/vchart", + "email": "dingling112@gmail.com" +} \ No newline at end of file From d1d6bf277852fde801944fff4d123d985c0b0ecf Mon Sep 17 00:00:00 2001 From: xile611 Date: Tue, 7 Jan 2025 11:24:39 +0800 Subject: [PATCH 7/7] fix: fix error of gradient in areachart, fix #3624 --- .../plugin/components/tooltip-handler/dom-tooltip-handler.ts | 2 +- .../vchart/src/plugin/components/tooltip-handler/utils/svg.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts b/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts index 0d76e029fb..dec268ef61 100644 --- a/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts +++ b/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts @@ -285,7 +285,7 @@ export class DomTooltipHandler extends BaseTooltipHandler { styleByRow = { ...styleByRow, ...getTextStyle(entry.valueStyle) }; } } else if (colName === 'shape') { - row.innerHTML = getSvgHtml(entry); + row.innerHTML = getSvgHtml(entry, `${this.id}_${index}`); } setStyleToDom(row, styleByRow); diff --git a/packages/vchart/src/plugin/components/tooltip-handler/utils/svg.ts b/packages/vchart/src/plugin/components/tooltip-handler/utils/svg.ts index 9283ddbba6..d2e11d2bef 100644 --- a/packages/vchart/src/plugin/components/tooltip-handler/utils/svg.ts +++ b/packages/vchart/src/plugin/components/tooltip-handler/utils/svg.ts @@ -5,7 +5,7 @@ import { Symbol } from '@visactor/vrender-core'; import { Bounds, isObject, isString } from '@visactor/vutils'; import type { ITooltipShapeActual } from '../../../../typings'; -export function getSvgHtml(option: ITooltipShapeActual | undefined, index?: number) { +export function getSvgHtml(option: ITooltipShapeActual | undefined, gradientId?: string) { if (!option || !option.hasShape || !option.shapeType) { return ''; } @@ -61,7 +61,7 @@ export function getSvgHtml(option: ITooltipShapeActual | undefined, index?: numb `; } if (isObject(shapeFill)) { - fillString = 'gradientColor' + (index ?? ''); + fillString = 'gradientColor' + (gradientId ?? ''); let gradient = ''; const stops = ((shapeFill as IGradientColor).stops ?? []) .map(s => ``)