Skip to content

Commit a8ed299

Browse files
authored
Merge pull request #3555 from VisActor/fix/tooltip-position-and-style
Fix/tooltip position and style
2 parents 8d93109 + 388e002 commit a8ed299

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "fix: fix style of dom tooltip\n\n",
5+
"type": "none",
6+
"packageName": "@visactor/vchart"
7+
}
8+
],
9+
"packageName": "@visactor/vchart",
10+
"email": "[email protected]"
11+
}

packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export class DomTooltipHandler extends BaseTooltipHandler {
240240

241241
if (contentDom && hasContent) {
242242
const columnDivs = [...(contentDom.children as any)] as HTMLElement[];
243+
setStyleToDom(contentDom, { whiteSpace: 'nowrap' });
243244

244245
columnDivs.forEach((colDiv, index) => {
245246
const colName = colDiv.getAttribute('data-col');

packages/vchart/src/plugin/components/tooltip-handler/utils/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const getScale = (element: HTMLElement, boundingClientRect?: DOMRect) =>
2626
if (element.offsetWidth > 0) {
2727
return boundingClientRect.width / element.offsetWidth;
2828
}
29-
return boundingClientRect.height / element.offsetHeight;
29+
return element.offsetHeight > 0 ? boundingClientRect.height / element.offsetHeight : 1;
3030
};
3131

3232
export const formatContent = (content: any) => {

0 commit comments

Comments
 (0)