import type { IPoint } from "../../core/util/IPoint"; import type { XYChart } from "./XYChart"; import type { XYSeries } from "./series/XYSeries"; import type { ISpritePointerEvent } from "../../core/render/Sprite"; import type { Axis } from "./axes/Axis"; import type { AxisRenderer } from "./axes/AxisRenderer"; import type { Tooltip } from "../../core/render/Tooltip"; import type { IDisposer } from "../../core/util/Disposer"; import { Container, IContainerSettings, IContainerPrivate, IContainerEvents } from "../../core/render/Container"; import { Graphics } from "../../core/render/Graphics"; import { Grid } from "./axes/Grid"; import type { IPointerEvent } from "../../core/render/backend/Renderer"; export interface IXYCursorSettings extends IContainerSettings { /** * X axis for the vertical line to snap to. When that axis has a `tooltip`, * the line follows it from cell to cell, such as from category to category. */ xAxis?: Axis; /** * Y axis for the horizontal line to snap to. When that axis has a * `tooltip`, the line follows it from cell to cell. */ yAxis?: Axis; /** * What dragging across the plot area does: zoom or select along X, Y or * both. * * @see {@link https://www.amcharts.com/docs/v5/charts/xy-chart/cursor/#Behavior} for more info * @default "none" */ behavior?: "zoomX" | "zoomY" | "zoomXY" | "selectX" | "selectY" | "selectXY" | "none"; /** * Pins the cursor at this horizontal position in the plot area: `0` is the * left edge, `1` the right. While set, the cursor ignores the pointer. */ positionX?: number; /** * Pins the cursor at this vertical position in the plot area: `0` is the * top edge, `1` the bottom. While set, the cursor ignores the pointer. */ positionY?: number; /** * Keeps the cursor visible when the pointer leaves the plot area. * * @default false */ alwaysShow?: boolean; /** * Series to snap to: the cursor jumps to the nearest data item among them. */ snapToSeries?: Array; /** * How `snapToSeries` measures "nearest": `"xy"` by straight distance, * `"x"` or `"y"` along one direction only. `"x!"` and `"y!"` do the same, * but only among the items under the pointer, one per series. * * @see {@link https://www.amcharts.com/docs/v5/charts/xy-chart/cursor/#snapping-to-series} for more info * @since 5.0.6 * @default "xy" */ snapToSeriesBy?: "xy" | "x" | "y" | "x!" | "y!"; /** * Cursors of other charts that move along with this one. * * They sync by position on the page, not by axis value, so vertical lines * follow each other only between charts stacked one above another, and * horizontal lines only between charts side by side. * * @see {@link https://www.amcharts.com/docs/v5/charts/xy-chart/cursor/#syncing-cursors} for more info * @since 5.1.4 */ syncWith?: Array; /** * How far in pixels the pointer must move between press and release for * a drag to zoom or select. A shorter move counts as a click. * * @since 5.2.20 * @default 1 */ moveThreshold?: number; /** * How far in pixels outside the plot area a press may start and still begin * a zoom or selection, which then starts at the plot area's edge. Makes it * easier to select from the very edge. * * @since 5.20.0 * @default 0 */ clickTolerance?: number; } export interface IXYCursorPrivate extends IContainerPrivate { /** * Current X/Y coordinates of the cursor. */ point?: IPoint; /** * Current horizontal position relative to the plot area (0-1). */ positionX?: number; /** * Current vertical position relative to the plot area (0-1). */ positionY?: number; /** * Horizontal position (0-1) where the current selection started. */ downPositionX?: number; /** * Vertical position (0-1) where the current selection started. */ downPositionY?: number; /** * The last point the cursor moved to, relative to the root. */ lastPoint?: IPoint; } export interface IXYCursorEvents extends IContainerEvents { /** * A drag across the plot area ended, zooming or selecting (`behavior` is * set). */ selectended: { originalEvent: IPointerEvent; target: XYCursor; }; /** * The pointer was pressed on the plot area, starting a zoom or selection * (`behavior` is set). */ selectstarted: { originalEvent: IPointerEvent; target: XYCursor; }; /** * The cursor moved over the plot area. */ cursormoved: { point: IPoint; target: XYCursor; originalEvent?: IPointerEvent; }; /** * The cursor was hidden as the pointer left the plot area. */ cursorhidden: { target: XYCursor; }; /** * A press on the plot area was released without moving past * `moveThreshold`, so no zoom or selection happened (`behavior` is set). * * @since 5.4.7 */ selectcancelled: { originalEvent: IPointerEvent; target: XYCursor; }; } /** * Crosshair lines over an [[XYChart]] that follow the pointer and show the * axis and series tooltips. Dragging can zoom or select (`behavior`). * * @see {@link https://www.amcharts.com/docs/v5/charts/xy-chart/cursor/} for more info * @important */ export declare class XYCursor extends Container { static className: string; static classNames: Array; _settings: IXYCursorSettings; _privateSettings: IXYCursorPrivate; _events: IXYCursorEvents; protected _alwaysShow: boolean; /** * The crosshair's vertical line, which follows the pointer along X. */ readonly lineX: Grid; /** * The crosshair's horizontal line, which follows the pointer along Y. */ readonly lineY: Grid; /** * The shaded area drawn while dragging. With a select `behavior`, it stays * after the release. */ readonly selection: Graphics; protected _movePoint: IPoint | undefined; protected _lastPoint: IPoint; protected _lastPoint2: IPoint; protected _tooltipX: boolean; protected _tooltipY: boolean; /** * The chart the cursor belongs to. */ chart: XYChart | undefined; protected _toX?: number; protected _toY?: number; protected _boundsTimeout?: IDisposer; protected _afterNew(): void; protected _setUpTouch(): void; protected _handleXLine(): void; protected _handleYLine(): void; protected _handleLineMove(key: string, ctrlKey?: boolean): void; protected _handleLineFocus(): void; protected _handleLineBlur(): void; _prepareChildren(): void; protected _handleSyncWith(): void; _updateChildren(): void; protected _updateXLine(tooltip: Tooltip): void; protected _updateYLine(tooltip: Tooltip): void; protected _drawLines(): void; /** * Places the cursor again at its last point, after the chart under it has * changed. A cursor with `alwaysShow` goes to `positionX` and `positionY`. */ updateCursor(): void; _setChart(chart: XYChart): void; protected _inPlot(point: IPoint): boolean; protected _handleCursorDown(event: ISpritePointerEvent): void; /** * Handles a press outside the plot area but within `clickTolerance`: the * press is clamped onto the plot edge and the selection starts there. * In-plot presses are handled by `_handleCursorDown` instead. */ protected _handleCursorDownGlobal(event: ISpritePointerEvent): void; protected _startSelection(local: IPoint, event: ISpritePointerEvent): void; protected _handleCursorUp(event: ISpritePointerEvent): void; protected _handleMove(event: ISpritePointerEvent): void; protected _getPosition(point: IPoint): IPoint; /** * Moves the cursor to a point, as if the pointer were there. * * @param point Point relative to the root; the last point if not given * @param skipEvent Do not dispatch `"cursormoved"` * @param originalEvent The pointer event behind the move, passed on with `"cursormoved"` */ handleMove(point?: IPoint, skipEvent?: boolean, originalEvent?: IPointerEvent): void; protected _getPoint(positionX: number, positionY: number): IPoint; protected _updateLines(x: number, y: number): void; protected _updateSelection(point: IPoint): void; protected _onHide(): void; protected _onShow(): void; protected _dispose(): void; } //# sourceMappingURL=XYCursor.d.ts.map