UNPKG

scichart

Version:

Fast WebGL JavaScript Charting Library and Framework

134 lines (133 loc) 5.7 kB
import { ModifierMouseArgs } from "../../Charting/ChartModifiers/ModifierMouseArgs"; import { EventHandler } from "../../Core/EventHandler"; import { EChart3DModifierType } from "../../types/ChartModifierType"; import { ChartModifierBase3D, IChartModifierBase3DOptions } from "./ChartModifierBase3D"; import { IRenderableSeries3D } from "../Visuals/RenderableSeries/BaseRenderableSeries3D"; import { HoveredChangedArgs3D } from "../Visuals/RenderableSeries/HoveredChangedArgs3D"; import { SelectionChangedArgs3D } from "../Visuals/RenderableSeries/SelectionChangedArgs3D"; /** * The type of the {@link ISeriesSelectionModifier3DOptions.onSelectionChanged } callback function */ export declare type TSelectionChangedCallback3D = (args: SelectionChangedArgs3D) => void; /** * The type of the {@link ISeriesSelectionModifier3DOptions.onHoverChanged } callback function */ export declare type THoveredChangedCallback3D = (args: HoveredChangedArgs3D) => void; export interface ISeriesSelectionModifier3DOptions extends IChartModifierBase3DOptions { /** * When true, Selection is enabled. Any series under the mouse or pointer device on mouseDown can be selected. * * Default `true` */ enableSelection?: boolean; /** * When true, hover is enabled. Any series under the mouse or pointer on mouseMove will be notified as mouseOver. * @remarks Enabling hover will decrease performance as a hit-test operation must be performed every mouse-move. * * Default `false` */ enableHover?: boolean; /** * Pixel radius used for hover and selection hit-testing around the mouse point. * A value of 0 means exact pixel only. * * Default `2` */ hitTestRadius?: number; /** * Optional callback for when any series is selected or deselected */ onSelectionChanged?: TSelectionChangedCallback3D | string; /** * Optional callback for when any series is hovered or unhovered */ onHoverChanged?: THoveredChangedCallback3D | string; /** * When true, if multiple series are hit at a pixel, the one with hit-point closest to camera is preferred. * Default `false` * * @note Use together with a larger `hitTestRadius` to improve hover behavior for thin 3D lines (a value of 10 instead of the default 2). */ prioritizeClosestToCamera?: boolean; } /** * The SeriesSelectionModifier3D provides series selection and hover behavior on a 3D {@link SciChart3DSurface} */ export declare class SeriesSelectionModifier3D extends ChartModifierBase3D { readonly type: EChart3DModifierType; /** * An array of currently selected series which can be observed by subscribing to the {@link selectionChanged} {@link EventHandler | event handler} */ selectedSeries: IRenderableSeries3D[]; /** * An array of currently hovered series which can be observed by subscribing to the {@link hoverChanged} {@link EventHandler | event handler} */ hoveredSeries: IRenderableSeries3D[]; /** * A selection-changed EventHandler. This is raised whenever any included series is selected or unselected. */ readonly selectionChanged: EventHandler<SelectionChangedArgs3D>; /** * A hover-changed EventHandler. This is raised whenever any included series is hovered or unhovered. */ readonly hoverChanged: EventHandler<HoveredChangedArgs3D>; /** * When true, Selection is enabled. Any series under the mouse or pointer device on mouseUp can be selected. * Default `true` */ enableSelection: boolean; /** * When true, hover is enabled. Any series under the mouse or pointer on mouseMove will be notified as mouseOver. * Default `false` */ enableHover: boolean; readonly hitTestRadius: number; readonly prioritizeClosestToCamera: boolean; private preventReentrancy; constructor(options?: ISeriesSelectionModifier3DOptions); /** @inheritDoc */ onAttach(): void; /** @inheritDoc */ onDetach(): void; /** @inheritDoc */ onAttachSeries(rs: any): void; /** @inheritDoc */ onDetachSeries(rs: any): void; /** @inheritDoc */ modifierMouseDown(args: ModifierMouseArgs): void; /** @inheritDoc */ modifierMouseMove(args: ModifierMouseArgs): void; /** @inheritDoc */ onParentSurfaceRendered(): void; /** @inheritDoc */ modifierMouseLeave(args: ModifierMouseArgs): void; /** @inheritDoc */ modifierPointerCancel(args: ModifierMouseArgs): void; /** @inheritDoc */ modifierMouseUp(args: ModifierMouseArgs): void; toJSON(): { type: string; options: Required<Omit<IChartModifierBase3DOptions, never>>; }; private onRenderableSeriesCollectionChanged; private updateHoverState; /** * Performs point-based hit-testing with a small pixel tolerance. * This improves hover detection for thin 3D lines without affecting click selection behavior. */ private findFirstHit; /** * Samples multiple screen positions around the mouse point up to searchRadius and * returns the hit whose world coordinate is closest to camera. */ private findClosestHitToCamera; private hitTestAtPoint; private hitTestAtPointAllSeries; private distanceSquaredToCamera; private getHitTestRadius; /** * This function called when the user sets series.isSelected = true elsewhere in code and we want to sync the modifier */ private updateSeriesSelected; private updateSeriesHovered; }