11import { DEFAULT_CHART_WIDTH , DEFAULT_CHART_HEIGHT } from '../../../constant/base' ;
2- import type { Options } from './constants' ;
32// eslint-disable-next-line no-duplicate-imports
43import { DEFAULT_OPTIONS } from './constants' ;
54import type { Maybe , IPoint , RenderMode } from '../../../typings' ;
@@ -28,21 +27,20 @@ import {
2827import type { IGroup } from '@visactor/vrender-core' ;
2928import type { AABBBounds } from '@visactor/vutils' ;
3029// eslint-disable-next-line no-duplicate-imports
31- import { isNumber , isObject , isValidNumber , isValid , throttle , isNil , isFunction } from '@visactor/vutils' ;
30+ import { isNumber , isObject , isValidNumber , isValid , isFunction } from '@visactor/vutils' ;
3231import type { IElement } from '@visactor/vgrammar-core' ;
3332import type { ILayoutModel } from '../../../model/interface' ;
3433import type { Compiler } from '../../../compile/compiler' ;
3534import type { IContainerSize } from '@visactor/vrender-components' ;
36- import { getTooltipAttributes } from './utils/attribute' ;
3735import type { IChartOption } from '../../../chart/interface' ;
3836import type { ITooltipSpec , Tooltip , TooltipHandlerParams } from '../../../component/tooltip' ;
3937// eslint-disable-next-line no-duplicate-imports
4038import { TooltipResult } from '../../../component/tooltip' ;
4139import type { IComponentPlugin , IComponentPluginService } from '../interface' ;
4240import { BasePlugin } from '../../base/base-plugin' ;
43- import type { ITooltipAttributes } from './interface' ;
4441import { getTooltipPatternValue } from '../../../component/tooltip/utils' ;
4542import type { IDimensionData , IDimensionInfo } from '../../../event/events/dimension/interface' ;
43+ import type { ITooltipHandlerOptions } from './interface' ;
4644
4745type ChangeTooltipFunc = ( visible : boolean , params : TooltipHandlerParams , data ?: TooltipData ) => TooltipResult ;
4846
@@ -62,7 +60,7 @@ export abstract class BaseTooltipHandler extends BasePlugin implements ITooltipH
6260
6361 // protected _style: ITooltipStyle = {};
6462
65- protected _option : Options ;
63+ protected _option : ITooltipHandlerOptions ;
6664
6765 protected _chartOption : IChartOption ;
6866
@@ -72,7 +70,6 @@ export abstract class BaseTooltipHandler extends BasePlugin implements ITooltipH
7270 }
7371
7472 protected _component : Tooltip ;
75- protected _attributes ?: ITooltipAttributes | null = null ;
7673
7774 protected _chartContainer : Maybe < HTMLElement > ;
7875 protected _compiler : Compiler ;
@@ -192,16 +189,17 @@ export abstract class BaseTooltipHandler extends BasePlugin implements ITooltipH
192189
193190 protected abstract _updateTooltip ( visible : boolean , params : TooltipHandlerParams ) : void ;
194191 protected abstract _removeTooltip ( ) : void ;
192+ protected abstract _getTooltipBoxSize (
193+ actualTooltip : ITooltipActual ,
194+ changePositionOnly : boolean
195+ ) : IContainerSize | undefined ;
195196
196197 /* -----需要子类继承的方法结束----- */
197198
198- protected _getDefaultOption ( ) : Options {
199+ protected _getDefaultOption ( ) : ITooltipHandlerOptions {
199200 const { offset } = this . _component . getSpec ( ) ;
200- return {
201- ...DEFAULT_OPTIONS ,
202- offsetX : offset ?. x ?? DEFAULT_OPTIONS . offsetX ,
203- offsetY : offset ?. y ?? DEFAULT_OPTIONS . offsetY
204- } ;
201+
202+ return offset ? { ...DEFAULT_OPTIONS , ...offset } : DEFAULT_OPTIONS ;
205203 }
206204
207205 /**
@@ -444,23 +442,6 @@ export abstract class BaseTooltipHandler extends BasePlugin implements ITooltipH
444442 return result ;
445443 } ;
446444
447- // 计算 tooltip 内容区域的宽高,并缓存结果
448- protected _getTooltipBoxSize ( actualTooltip : ITooltipActual , changePositionOnly : boolean ) : IContainerSize | undefined {
449- if ( ! changePositionOnly || isNil ( this . _attributes ) ) {
450- const chartTheme = this . _chartOption ?. getTheme ( ) ?? { } ;
451- this . _attributes = getTooltipAttributes ( actualTooltip , this . _component . getSpec ( ) , chartTheme ) ;
452- }
453- const { panel, panelDomHeight } = this . _attributes ?? { } ;
454- // canvas模式下, size需要考虑border size, 目的是为了精准判断边界是否超出画布,达到confine效果
455- // html模式不提供confine, 所以不考虑精准计算size
456- const isCanvas = this . _component . getSpec ( ) . renderMode === 'canvas' ;
457-
458- return {
459- width : panel ?. width + ( isCanvas ? panel . lineWidth : 0 ) ,
460- height : ( panelDomHeight ?? panel ?. height ) + ( isCanvas ? panel . lineWidth : 0 )
461- } ;
462- }
463-
464445 protected _getParentElement ( spec : ITooltipSpec ) : HTMLElement {
465446 return spec . parentElement as any ;
466447 }
0 commit comments