import type { IDeletable } from "../../../Core/IDeletable"; import type { IHoverable } from "../../../Core/IHoverable"; import type { IWithXYAxes } from "../../../Core/IWithXYAxes"; import type { ESurfaceType } from "../../../types/SurfaceType"; import type { AxisBase2D } from "../Axis/AxisBase2D"; import type { SciChartSurfaceBase } from "../SciChartSurfaceBase"; import type { INotifyOnDpiChanged } from "../TextureManager/DpiHelper"; import type { ECoordinateMode } from "./types/ECoordinateMode"; import type { EAnnotationClippingMode } from "../../../types/AnnotationClippingMode"; import type { IOrderedRenderable } from "../../../types/OrderedRenderable"; import { EAnnotationLayer } from "./types/EAnnotationLayer"; import { EAnnotationType } from "./types/EAnnotationType"; import { Point } from "../../../Core/Point"; /** * Defines the interface to an Annotation - a type of marker, text label, line or custom UI overlay on a 2D Cartesian {@link SciChartSurface} */ export interface IAnnotation extends IDeletable, INotifyOnDpiChanged, IHoverable, IWithXYAxes, IOrderedRenderable { /** * A unique Id for the {@link IAnnotation} */ readonly id: string; /** * @description annotation type. See {@link EAnnotationType} for a list of values */ readonly type: EAnnotationType; /** * @description compatible surface types. See {@link EAnnotationType} for a list of values */ readonly surfaceTypes: ESurfaceType[]; /** * @description defines if the annotation is SVG annotation */ readonly isSvgAnnotation: boolean; /** * @description defines if the annotation is rendered as HTMLElement or on WebGL Canvas via RenderContext * @readonly Check for other versions that are drawn with alternative approaches if needed */ readonly isDomAnnotation: boolean; /** * Gets the bound {@link AxisBase2D | XAxis} for this {@link IAnnotation}. */ readonly xAxis: AxisBase2D | undefined; /** * Gets the bound {@link AxisBase2D | YAxis} for this {@link IAnnotation}. */ readonly yAxis: AxisBase2D | undefined; /** * @description The layer to place the annotation on. See {@link EAnnotationLayer} for a list of values * @remarks applicable only to WebGL annotations */ annotationLayer: EAnnotationLayer; /** * The Id of the parent {@link CompositeAnnotation} of this annotation. * Returns `null` if there is no parent and the annotation is a top-level annotation. */ parentAnnotationId: string | null; /** * @description callback which notifies the parent {@link SciChartSurface} it's time to draw */ invalidateParentCallback: (options?: { force?: boolean; svgOnly?: boolean; }) => void; /** * @summary The current XAxis Id that this {@link IAnnotation} is bound to. If undefined it will use the first X axis attached to SciChartSurface * @description By default all Annotations will draw on the first X,Y axis pair in SciChart. * If you want this to change, you must add a second axis to your {@link SciChartSurface} and link the {@link IAnnotation} by Axis Id. * * For example: * ```ts * const sciChartSurface: SciChartSurface; * const primaryXAxis = new NumericAxis(wasmContext); * const primaryYAxis = new NumericAxis(wasmContext); * * const secondaryXAxis = new NumericAxis(wasmContext); // For subsequent X,Y axis set an Id * secondaryXAxis.id = "SecondaryXAxis"; * const secondaryYAxis = new NumericAxis(wasmContext); * secondaryYAxis.id = "SecondaryYAxis"; * * // Add all Axis to the chart * sciChartSurface.xAxes.add(primaryXAxis); * sciChartSurface.yAxes.add(primaryYAxis); * sciChartSurface.xAxes.add(secondaryXAxis); * sciChartSurface.yAxes.add(secondaryYAxis); * * // Add an Annotation on the default axis * const annotation = new LineAnnotation(wasmContext); * sciChartSurface.renderableSeries.add(annotation); * * // Add an Annotation on the specific axis * const annotation2 = new LineAnnotation(wasmContext); * annotation2.xAxisId = "SecondaryXAxis"; * annotation2.yAxisId = "SecondaryYAxis"; * sciChartSurface.renderableSeries.add(annotation2); * ``` */ xAxisId: string | undefined; /** * @summary The current YAxis Id that this {@link IAnnotation} is bound to. If undefined it will use the first X axis attached to SciChartSurface * @description By default all Annotations will draw on the first X,Y axis pair in SciChart. * If you want this to change, you must add a second axis to your {@link SciChartSurface} and link the {@link IAnnotation} by Axis Id. * * For example: * ```ts * const sciChartSurface: SciChartSurface; * const primaryXAxis = new NumericAxis(wasmContext); * const primaryYAxis = new NumericAxis(wasmContext); * * const secondaryXAxis = new NumericAxis(wasmContext); // For subsequent X,Y axis set an Id * secondaryXAxis.id = "SecondaryXAxis"; * const secondaryYAxis = new NumericAxis(wasmContext); * secondaryYAxis.id = "SecondaryYAxis"; * * // Add all Axis to the chart * sciChartSurface.xAxes.add(primaryXAxis); * sciChartSurface.yAxes.add(primaryYAxis); * sciChartSurface.xAxes.add(secondaryXAxis); * sciChartSurface.yAxes.add(secondaryYAxis); * * // Add an Annotation on the default axis * const annotation = new LineAnnotation(wasmContext); * sciChartSurface.renderableSeries.add(annotation); * * // Add an Annotation on the specific axis * const annotation2 = new LineAnnotation(wasmContext); * annotation2.xAxisId = "SecondaryXAxis"; * annotation2.yAxisId = "SecondaryYAxis"; * sciChartSurface.renderableSeries.add(annotation2); * ``` */ yAxisId: string | undefined; /** * @description the X1 coordinate of the annotation * @remarks The X1 coordinate obeys {@link xCoordinateMode} which defines whether the X1 coordinate is a pixel, data-value or relative coordinate */ x1: number; /** * @description the X2 coordinate of the annotation * @remarks The X1 coordinate obeys {@link xCoordinateMode} which defines whether the X2 coordinate is a pixel, data-value or relative coordinate */ x2: number; /** * @description the Y1 coordinate of the annotation * @remarks The Y1 coordinate obeys {@link xCoordinateMode} which defines whether the Y1 coordinate is a pixel, data-value or relative coordinate */ y1: number; /** * @description the Y2 coordinate of the annotation * @remarks The Y2 coordinate obeys {@link xCoordinateMode} which defines whether the Y2 coordinate is a pixel, data-value or relative coordinate */ y2: number; /** * The X-Coordinate mode. See {@link ECoordinateMode} for a list of values * @remarks Want to display an annotation stretching across the entire width (or height) or the {@link SciChartSurface}? * The {@link ECoordinateMode} enum has options which allow for relative, absolute or pixel coordinates which define annotation * placement. */ xCoordinateMode: ECoordinateMode; /** * The Y-Coordinate mode. See {@link ECoordinateMode} for a list of values * @remarks Want to display an annotation stretching across the entire width (or height) or the {@link SciChartSurface}? * The {@link ECoordinateMode} enum has options which allow for relative, absolute or pixel coordinates which define annotation * placement. */ yCoordinateMode: ECoordinateMode; /** * @description if true, the annotation is editable (can be dragged and manipulated by the user) */ isEditable: boolean; /** * @description if true, the annotation is hidden */ isHidden: boolean; /** * @description the parent SciChartSurfaceBase for this annotation */ parentSurface: SciChartSurfaceBase; /** * @description if true, the chart is vertical */ isVerticalChart: boolean; /** * @description When true, the annotation is selected and resize adorners will be displayed */ isSelected: boolean; /** * Sets an opacity override for the entire annotation, from 0..1 */ opacity: number; /** * The clipping mode of the annotation */ clipping: string | EAnnotationClippingMode; /** * The clipping mode of the annotation adorners */ adornerClipping: string | EAnnotationClippingMode; /** * @description Called when the annotation is attached to a parent SciChartSurface. */ onAttach(scs: SciChartSurfaceBase): void; /** * @description Called when the annotation is detached from a parent SciChartSurface. */ onDetach(): void; /** * Convert the object to a definition that can be serialized to JSON, or used directly with the builder api */ toJSON(): any; /** * Checks if passed point on the canvas is inside annotation borders * @param x the X screen coordinate relative to canvas * @param y the Y screen coordinate relative to canvas */ checkIsClickedOnAnnotation(x: number, y: number): boolean; /** * Resolves the current interaction cursor for this annotation. */ resolveInteractionCursor(mousePoint?: Point): string | undefined; /** Used internally - Sets references to X and Y axes */ linkAxes(): void; }