UNPKG

chartjs-plugin-cursors

Version:

Chart.js plugin to draw and sync cursor lines

53 lines (47 loc) 1.38 kB
import { Chart, ChartType } from "chart.js"; export interface CursorPosition { previousX?: number; previousY?: number; x?: number; y?: number; } export interface CursorLineOptions { color: string; width: number; dashPattern: number[]; } export interface CursorOptions { enabled: boolean; visible?: boolean; positions?: CursorPosition[]; line?: CursorLineOptions; startTime?: number; callbacks?: { afterMove?: (positions: CursorPosition[]) => void; }; } export interface CursorState { enabled: boolean; visible: boolean; startTime: number | undefined; suppressUpdate: boolean; ignoreNextEvents: number; selected: number; positions: CursorPosition[]; centreCursors: (chart: Chart) => void; setStartTime: (time: number) => void; hitTest: (x: number, y: number, threshold: number) => number; } declare module "chart.js" { interface Chart { cursors: CursorState; } interface PluginOptionsByType<TType extends ChartType> { cursors?: CursorOptions; } interface Plugin<TType extends ChartType> { drawCursors: (chart: Chart) => void; centreCursors: (chart: Chart) => void; hitTestCursor: (chart: Chart, x: number, y: number, threshold: number) => number; } }