import { PlotArea, Bounds, AxisOptions } from '../../../types'; import { Scale } from '../../../scales'; import { Series } from '../../../core/Series'; import { TooltipData, TooltipOptions, TooltipTheme, TooltipTemplate, ShowTooltipOptions, TooltipEventMap } from './types'; import { ChartTheme } from '../../../theme'; export interface TooltipManagerConfig { /** Canvas 2D context for rendering */ overlayCtx: CanvasRenderingContext2D; /** Chart theme (for auto-selecting tooltip theme) */ chartTheme: ChartTheme; /** Function to get current plot area */ getPlotArea: () => PlotArea; /** Function to get all series */ getSeries: () => Series[]; /** Function to convert pixel X to data X */ pixelToDataX: (px: number) => number; /** Function to convert pixel Y to data Y */ pixelToDataY: (py: number) => number; /** Function to get X scale */ getXScale: () => Scale; /** Function to get Y scales */ getYScales: () => Map; /** Function to get view bounds */ getViewBounds: () => Bounds; /** Function to get X axis options */ getXAxisOptions?: () => AxisOptions; /** Function to get Y axis options for a series axis id */ getYAxisOptions?: (axisId?: string) => AxisOptions | undefined; /** Initial options */ options?: TooltipOptions; } export declare class TooltipManager { private ctx; private getPlotArea; private getSeries; private pixelToDataX; private pixelToDataY; private getXScale; private getYScales; private getViewBounds; private getXAxisOptions?; private getYAxisOptions?; private options; private theme; private positioner; private renderer; private templates; private events; private activeTooltips; private tooltipIdCounter; private showTimeoutId; private hideTimeoutId; private lastCursorX; private lastCursorY; private hoveredSeriesId; private hoveredDataIndex; private cachedNearestResult; private snapMode; private largeDatasetThreshold; private lastKnownDataSize; private hysteresisRatio; private suspended; constructor(config: TooltipManagerConfig); /** * Register built-in templates */ private registerBuiltinTemplates; /** * Configure tooltip options */ configure(options: TooltipOptions): void; /** * Get current options */ getOptions(): TooltipOptions; /** * Enable/disable tooltips */ setEnabled(enabled: boolean): void; /** * Check if tooltips are enabled */ isEnabled(): boolean; /** * Suspend tooltip display (used during drag operations) * When suspended, tooltips are immediately hidden and cursor movements are ignored */ setSuspended(suspended: boolean): void; /** * Check if tooltips are suspended */ isSuspended(): boolean; /** * Set tooltip theme */ setTheme(theme: TooltipTheme | string): void; /** * Update theme based on chart theme */ updateChartTheme(chartTheme: ChartTheme): void; /** * Get current theme */ getTheme(): TooltipTheme; /** * Register a custom template */ registerTemplate(template: TooltipTemplate): void; /** * Get a template by ID */ getTemplate(id: string): TooltipTemplate | undefined; /** * Handle cursor movement - main entry point for hover detection * Optimized with hysteresis to prevent jumping between nearby points */ handleCursorMove(pixelX: number, pixelY: number): void; /** * Handle cursor leave */ handleCursorLeave(): void; /** * Get total number of data points across all visible series */ private getTotalDataPoints; /** * Determine the effective snap mode based on configuration and data size */ private getEffectiveSnapMode; /** * Perform tooltip update with hysteresis to prevent jumping. * The tooltip "sticks" to the current point unless the cursor is * significantly closer to a new point. */ private performTooltipUpdateWithHysteresis; /** * Handle heatmap and crosshair tooltip types (fallback) */ private performFallbackTooltipUpdate; private buildAxisFormat; /** * Find data point by X coordinate only (O(log n) - fastest method) * Best for very large datasets where precision is less important than speed */ private findDataPointByXOnly; /** * Optimized nearest data point finder */ private findNearestDataPointOptimized; /** * Find heatmap cell under cursor */ private findHeatmapCell; /** * Binary search for closest value */ private binarySearchClosest; /** * Build crosshair tooltip data */ private buildCrosshairTooltip; /** * Schedule showing a tooltip */ private scheduleShow; /** * Schedule hiding tooltips */ private scheduleHide; private clearShowTimeout; private clearHideTimeout; /** * Show a tooltip with the given data */ private showTooltip; /** * Update tooltip position */ private updateTooltipPosition; /** * Get template ID for a tooltip type */ private getTemplateIdForType; /** * Show a tooltip programmatically */ show(data: TooltipData, options?: ShowTooltipOptions): string; /** * Hide a specific tooltip */ hide(tooltipId: string): void; /** * Hide all tooltips immediately */ hideAll(): void; /** * Render all active tooltips */ render(): void; /** * Check if any tooltip is currently visible */ hasActiveTooltip(): boolean; /** * Subscribe to tooltip events */ on(event: K, handler: (data: TooltipEventMap[K]) => void): void; /** * Unsubscribe from tooltip events */ off(event: K, handler: (data: TooltipEventMap[K]) => void): void; /** * Destroy the tooltip manager */ destroy(): void; } /** * Create a tooltip manager */ export declare function createTooltipManager(config: TooltipManagerConfig): TooltipManager;