8000 Feat/tooltip position inside by xile611 · Pull Request #3930 · VisActor/VChart · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feat/tooltip position inside #3930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 27, 2025
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
11 changes: 11 additions & 0 deletions common/changes/@visactor/vchart/develop_2025-04-25-09-58.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "feat: tooltip support inside position\n\n",
"type": "none",
"packageName": "@visactor/vchart"
}
],
"packageName": "@visactor/vchart",
"email": "dingling112@gmail.com"
}
6 changes: 6 additions & 0 deletions packages/vchart/src/plugin/components/tooltip-handler/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ export abstract class BaseTooltipHandler extends BasePlugin implements ITooltipH
case -2:
calcPos[posKey] = dim1 - boxSize * tooltipSizeScale - dimOffset;
break;
case -1.5:
calcPos[posKey] = dim1 + dimOffset;
break;
case 0:
calcPos[posKey] = (dim1 + dim2) / 2 - (boxSize * tooltipSizeScale) / 2;
break;
Expand All @@ -331,6 +334,9 @@ export abstract class BaseTooltipHandler extends BasePlugin implements ITooltipH
case 1:
calcPos[posKey] = (dim1 + dim2) / 2 + dimOffset;
break;
case 1.5:
calcPos[posKey] = dim2 - boxSize * tooltipSizeScale - dimOffset;
break;
case 2:
calcPos[posKey] = dim2 + dimOffset;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,31 @@ export const getActualTooltipPositionValue = (
return result;
};

// 'left' | 'centerLeft' | 'center' | 'centerRight' | 'right'
// 'top' | 'centerTop' | 'center' | 'centerBottom' | 'bottom'
export type TooltipPositionType = -2 | -1 | 0 | 1 | 2;
// 'left' | 'innerLeft' | 'centerLeft' | 'center' | 'centerRight' | 'innerRight' | 'right'
// 'top' | 'innerTop' | 'centerTop' | 'center' | 'centerBottom' | 'innerBottom' | 'bottom'
export type TooltipPositionType = -2 | -1.5 | -1 | 0 | 1 | 1.5 | 2;

/** position 对齐方式在 x、y 分量下的分解 */
export const positionType: Record<TooltipFixedPosition, [TooltipPositionType, TooltipPositionType]> = {
left: [-2, 0],
right: [2, 0],
top: [0, -2],
bottom: [0, 2],

insideTop: [0, -1.5],
insideBottom: [0, 1.5],
insideLeft: [-1.5, 0],
insideRight: [1.5, 0],

insideTopLeft: [-1.5, -1.5],
insideTopRight: [1.5, -1.5],
insideBottomLeft: [-1.5, 1.5],
insideBottomRight: [1.5, 1.5],

lt: [-2, -2],
tl: [-2, -2],
rt: [2, -2],
tr: [2, -2],
bottom: [0, 2],
bl: [-2, 2],
lb: [-2, 2],
br: [2, 2],
Expand Down
42 changes: 41 additions & 1 deletion packages/vchart/src/typings/tooltip/position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,47 @@ export type TooltipFixedPosition =
*/
| 'centerRight'
/** tooltip 显示在鼠标所在图形中心位置(旧版兼容,建议用 `'center'`) */
| 'inside';
| 'inside'
/**
* tooltip 显示在鼠标所在图形的内侧顶部
* @since 1.13.10
*/
| 'insideTop'
/**
* tooltip 显示在鼠标所在图形的内侧底部
* @since 1.13.10
*/
| 'insideBottom'
/**
* tooltip 显示在鼠标所在图形的内侧左侧
* @since 1.13.10
*/
| 'insideLeft'
/**
* tooltip 显示在鼠标所在图形的内侧右侧
* @since 1.13.10
*/
| 'insideRight'
/**
* tooltip 显示在鼠标所在图形的内侧左上角
* @since 1.13.10
*/
| 'insideTopLeft'
/**
* tooltip 显示在鼠标所在图形的内侧右上角
* @since 1.13.10
*/
| 'insideTopRight'
/**
* tooltip 显示在鼠标所在图形的内侧左下角
* @since 1.13.10
*/
| 'insideBottomLeft'
/**
* tooltip 显示在鼠标所在图形的内侧右下角
* @since 1.13.10
*/
| 'insideBottomRight';

export type TooltipPositionMode =
/** tooltip 固定在鼠标指针附近 */
Expand Down
Loading
0