scichart
Version:
Fast WebGL JavaScript Charting Library and Framework
136 lines (135 loc) • 5.99 kB
TypeScript
import { Point } from "../../../Core/Point";
import { EHorizontalAnchorPoint, EVerticalAnchorPoint } from "../../../types/AnchorPoint";
import { Size } from "../../../types/Size";
import { ModifierMouseArgs } from "../../ChartModifiers/ModifierMouseArgs";
import { CoordinateCalculatorBase } from "../../Numerics/CoordinateCalculators/CoordinateCalculatorBase";
import { SciChartSurfaceBase } from "../SciChartSurfaceBase";
import { AnnotationBase, IAnnotationBaseOptions } from "./AnnotationBase";
/**
* Options passed to the constructor of a {@link DomAnnotationBase}, used to configure it at instantiation time
*/
export interface IDomAnnotationOptions extends IAnnotationBaseOptions {
xCoordShift?: number;
yCoordShift?: number;
/**
* Sets vertical anchor point
*/
verticalAnchorPoint?: EVerticalAnchorPoint;
/**
* Sets horizontal anchor point
*/
horizontalAnchorPoint?: EHorizontalAnchorPoint;
/**
* If true, the whole chart will be redrawn after the annotation is updated.
* Default is false to allow svg/html annotations to be updated without redrawing the whole chart, but set this true if you need to synchronise this annotation with native chart updates.
* Can be set globally using SciChartDefaults.alwaysRedrawFullChartOnSvgChange
*/
reDrawChartOnChange?: boolean;
}
export declare abstract class DomAnnotationBase extends AnnotationBase {
readonly isDomAnnotation: boolean;
isDeleted: boolean;
protected xCoordShiftProperty: number;
protected yCoordShiftProperty: number;
protected verticalAnchorPointProperty: EVerticalAnchorPoint;
protected horizontalAnchorPointProperty: EHorizontalAnchorPoint;
protected prevX1Coordinate: number;
protected prevY1Coordinate: number;
protected sizeProperty: Size;
protected xCoordSvgTransProperty: number;
protected yCoordSvgTransProperty: number;
reDrawChartOnChange: boolean;
/**
* Creates an instance of an HtmlAnnotation
* @param options Optional parameters of type {@link IHtmlCustomAnnotationOptions} used to configure the annotation on construction
*/
constructor(options?: IDomAnnotationOptions);
onAttach(scs: SciChartSurfaceBase): void;
/**
* Gets or sets an offset to shift X-coordinates
*/
get xCoordShift(): number;
/**
* Gets or sets an offset to shift X-coordinates
*/
set xCoordShift(value: number);
/**
* Gets or sets an offset to shift Y-coordinates
*/
get yCoordShift(): number;
/**
* Gets or sets an offset to shift Y-coordinates
*/
set yCoordShift(value: number);
/**
* Gets or sets vertical anchor point
*/
get verticalAnchorPoint(): EVerticalAnchorPoint;
/**
* Gets or sets vertical anchor point
*/
set verticalAnchorPoint(value: EVerticalAnchorPoint);
/**
* Gets or sets horizontal anchor point
*/
get horizontalAnchorPoint(): EHorizontalAnchorPoint;
/**
* Gets or sets horizontal anchor point
*/
set horizontalAnchorPoint(value: EHorizontalAnchorPoint);
suspendInvalidate(): void;
resumeInvalidate(): void;
/**
* Updates the annotation position, with the {@link CoordinateCalculatorBase | Coordinate Calculators} passed in
* @param xCalc The XAxis {@link CoordinateCalculatorBase | CoordinateCalculator} applied to this annotation
* @param yCalc The YAxis {@link CoordinateCalculatorBase | CoordinateCalculator} applied to this annotation
* @param xCoordSvgTrans X-coordinate translation which is needed to use SVG canvas having the whole chart size
* @param yCoordSvgTrans Y-coordinate translation which is needed to use SVG canvas having the whole chart size
*/
abstract update(xCalc: CoordinateCalculatorBase, yCalc: CoordinateCalculatorBase, xCoordSvgTrans: number, yCoordSvgTrans: number): void;
calcDragDistance(xyValues: Point): void;
/**
* Gets the annotation borders in real, pixel coordinates relative to the master html element containing the surface.
* @example
* // Say we have a data-value of "15" on the chart's xAxis.
* // Step 1: We calculate the screen coordinate of it via the coordinateCalculator (or take it from our stored annotationBorders property),
* // Step 2: Multiply that value by DpiHelper.PIXEL_RATIO
* // Step 3: Add the already-scaled {xCoordSvgTrans} value to get the real coordinate on the SVG canvas.
*
* @note This process is done for all 4 borders x1, x2, y1, y2.
*/
getAnnotationBorders(ordered?: boolean, notScaled?: boolean): {
x1: number;
x2: number;
y1: number;
y2: number;
};
/**
* Returns annotation borders for the {@link AdornerLayer} which has the size of the whole canvas
* @param ordered flag to return x and y values in ascending order
*/
getAdornerAnnotationBorders(ordered?: boolean): {
x1: number;
x2: number;
y1: number;
y2: number;
};
onDragStarted(args: ModifierMouseArgs): boolean;
/** @inheritDoc */
delete(): void;
toJSON(): {
type: import("./IAnnotation").EAnnotationType;
options: Required<Omit<IAnnotationBaseOptions, never>>;
};
protected checkIsClickedOnAnnotationInternal(x: number, y: number): boolean;
protected updateAdornerInner(): void;
protected abstract selectLayerRoot(): void;
protected notifyPropertyChanged(propertyName: string): void;
protected abstract getSize(): Size;
/**
* Calculates and sets annotationBorders
* @protected
*/
protected calcAndSetAnnotationBorders(xCalc: CoordinateCalculatorBase, yCalc: CoordinateCalculatorBase): void;
svgStringAdornerTemplate(x1: number, y1: number, x2: number, y2: number): string;
}