import { Bounds, PlotArea } from '../../types'; import { Scale } from '../../scales'; import { Series } from '../series/Series'; import { EventEmitter } from '../EventEmitter'; /** Represents a single selected data point */ export interface SelectedPoint { seriesId: string; index: number; x: number; y: number; } /** Selection mode for multi-select operations */ export type SelectionMode = 'single' | 'add' | 'remove' | 'toggle'; /** Event data for point selection changes */ export interface PointSelectEvent { points: SelectedPoint[]; mode: SelectionMode; source: 'click' | 'box' | 'api'; } /** Event data for region/box selection */ export interface RegionSelectEvent { bounds: Bounds; containedPoints: SelectedPoint[]; } /** Selection event map */ export interface SelectionEventMap { pointSelect: PointSelectEvent; regionSelect: RegionSelectEvent; selectionChange: { selected: SelectedPoint[]; previous: SelectedPoint[]; }; selectionClear: undefined; } /** Hit-test result for a single point */ export interface HitTestResult { seriesId: string; index: number; x: number; y: number; distance: number; pixelX: number; pixelY: number; } /** Selection manager configuration */ export interface SelectionConfig { /** Enable selection (default: true) */ enabled?: boolean; /** Maximum distance in pixels for hit-testing (default: 20) */ hitRadius?: number; /** Allow multi-selection with Ctrl+click (default: true) */ multiSelect?: boolean; /** Enable box selection with Shift+drag (default: true) */ boxSelect?: boolean; /** Highlight style for selected points */ highlightStyle?: { color?: string; size?: number; ringWidth?: number; }; } /** Context for selection operations */ export interface SelectionContext { getSeries: () => Map; getPlotArea: () => PlotArea; getXScale: () => Scale; getYScales: () => Map; getPrimaryYAxisId: () => string; events: EventEmitter; requestRender: () => void; } export declare class SelectionManager { private ctx; private config; private selected; private isBoxSelecting; private boxStart; private boxEnd; constructor(ctx: SelectionContext, config?: SelectionConfig); configure(config: Partial): void; getConfig(): SelectionConfig; setEnabled(enabled: boolean): void; isEnabled(): boolean; /** * Hit-test at a pixel coordinate to find the nearest data point */ hitTest(pixelX: number, pixelY: number, radius?: number): HitTestResult | null; /** * Hit-test all points within a rectangular region */ hitTestRegion(bounds: Bounds): HitTestResult[]; /** * Select specific points programmatically */ selectPoints(points: Array<{ seriesId: string; indices: number[]; }>, mode?: SelectionMode): void; /** * Get all currently selected points */ getSelectedPoints(): SelectedPoint[]; /** * Check if a specific point is selected */ isPointSelected(seriesId: string, index: number): boolean; /** * Get selected points for a specific series */ getSelectedForSeries(seriesId: string): number[]; /** * Clear all selections */ clearSelection(): void; /** * Get selection count */ getSelectionCount(): number; /** * Handle click event for selection */ handleClick(pixelX: number, pixelY: number, ctrlKey: boolean, shiftKey: boolean): void; /** * Start box selection */ startBoxSelection(pixelX: number, pixelY: number): void; /** * Update box selection during drag */ updateBoxSelection(pixelX: number, pixelY: number): void; /** * Complete box selection */ completeBoxSelection(additive?: boolean): void; /** * Cancel box selection */ cancelBoxSelection(): void; /** * Check if box selection is active */ isBoxSelectActive(): boolean; /** * Get current box selection rectangle (for rendering) */ getBoxSelectionRect(): { x: number; y: number; width: number; height: number; } | null; /** * Render selected point highlights */ render(ctx: CanvasRenderingContext2D, plotArea: PlotArea): void; /** * Binary search to find nearest index in sorted array */ private findNearestIndex; /** * Destroy the selection manager */ destroy(): void; }