scichart
Version:
Fast WebGL JavaScript Charting Library and Framework
277 lines (276 loc) • 9.77 kB
TypeScript
import { Point } from "../../../Core/Point";
import { Rect } from "../../../Core/Rect";
import { Thickness } from "../../../Core/Thickness";
import { ELabelPlacement } from "../../../types/LabelPlacement";
import { ESurfaceType } from "../../../types/SurfaceType";
import { ModifierMouseArgs } from "../../ChartModifiers/ModifierMouseArgs";
import { Pen2DCache } from "../../Drawing/Pen2DCache";
import { WebGlRenderContext2D } from "../../Drawing/WebGlRenderContext2D";
import { CoordinateCalculatorBase } from "../../Numerics/CoordinateCalculators/CoordinateCalculatorBase";
import { SciChartSurface } from "../SciChartSurface";
import { TDpiChangedEventArgs } from "../TextureManager/DpiHelper";
import { IAnnotationBaseOptions } from "./AnnotationBase";
import { IAdornerProvider } from "./IAdornerProvider";
import { EAnnotationType, IAnnotation } from "./IAnnotation";
import { RenderContextAnnotationBase } from "./RenderContextAnnotationBase";
/**
* @summary The interface describing a {@link LineAnnotation}
*/
export interface ILineAnnotation extends IAnnotation, IAdornerProvider {
/**
* Gets the stroke for the {@link RolloverLineAnnotation}
*/
stroke: string;
/**
* Gets the strokeThickness for the {@link LineAnnotation}
*/
strokeThickness: number;
/**
* Gets the strokeDashArray for the {@link LineAnnotation}
*/
strokeDashArray: number[];
/**
* Gets the showLabel for the {@link LineAnnotation}
*/
showLabel: boolean;
/**
* Gets the axisLabelStroke for the {@link LineAnnotation}
*/
axisLabelStroke: string;
/**
* Gets the axisLabelFill for the {@link LineAnnotation}
*/
axisLabelFill: string;
/**
* Gets the axisFontSize for the {@link LineAnnotation}
*/
axisFontSize: number;
/**
* Gets the axisFontSize for the {@link LineAnnotation}
*/
axisFontFamily: string;
/**
* Gets the labelPlacement for the {@link LineAnnotation}
*/
labelPlacement: ELabelPlacement;
/**
* Gets the labelValue for the {@link LineAnnotation}
*/
labelValue: string;
/**
* Extra padding (in pixels) applied to line annotation labels
*
* @default new Thickness(0, 3, 0, 3) // 3px of x-padding and 0px of y-padding
*/
labelPadding: Thickness;
/**
* Gets or sets the corner/border radius for the line annotation labels, in pixels
*/
labelCornerRadius: number;
}
/**
* Options passed to the constructor of a {@link LineAnnotation}, used to configure it at instantiation time
*/
export interface ILineAnnotationOptions extends IAnnotationBaseOptions {
/**
* The stroke for the {@link LineAnnotation}
* @remarks Acceptable values include RGB format e.g. ```#FF0000```, RGBA format e.g. ```#FF000077`` and RGBA format e.g. ```rgba(255,0,0,0.5)```
*/
stroke?: string;
/**
* The strokeThickness for the {@link LineAnnotation}
*/
strokeThickness?: number;
/**
* The strokeDashArray for the {@link LineAnnotation}
*/
strokeDashArray?: number[];
/**
* The showLabel for the {@link LineAnnotation}
*/
showLabel?: boolean;
/**
* The axisLabelStroke for the {@link LineAnnotation}
*/
axisLabelStroke?: string;
/**
* The axisLabelFill for the {@link LineAnnotation}
*/
axisLabelFill?: string;
/**
* The axisLabelFill for the {@link LineAnnotation}
*/
axisFontSize?: number;
/**
* The axisLabelFill for the {@link LineAnnotation}
*/
axisFontFamily?: string;
/**
* The labelPlacement for the {@link LineAnnotation}
*/
labelPlacement?: ELabelPlacement;
/**
* The labelValue for the {@link LineAnnotation}
*/
labelValue?: string;
/**
* Extra padding applied to line annotation labels
*
* @default new Thickness(2, 4, 2, 4) // 2px of y-padding and 4px of x-padding
*/
labelPadding?: Thickness;
/**
* The corner/border radius for the line annotation labels, in pixels
*
* Default `2`
*/
labelCornerRadius?: number;
}
/**
* @summary The {@link LineAnnotation} provides an {@link AnnotationBase | Annotation} which draws a line at
* specific x1x2 y1y2 over the {@link SciChartSurface}
* @description
* To add a {@link LineAnnotation} to a {@link SciChartSurface}, use the following code:
* ```ts
* const sciChartSurface: SciChartSurface;
* const lineAnnotation = new LineAnnotation({ x1: 1, x2: 2, y1: 3, y2: 4, stroke: "#FF0000"});
* sciChartSurface.annotations.add(lineAnnotation);
* ```
* @remarks Uses the fast WebGL/WebAssembly {@link WebGL2RenderingContext} for rendering
*/
export declare class LineAnnotation extends RenderContextAnnotationBase implements ILineAnnotation {
/** @inheritDoc */
readonly type: EAnnotationType;
/** @inheritDoc */
readonly surfaceTypes: ESurfaceType[];
protected strokePenCache: Pen2DCache;
protected axisFontSizeProperty?: number;
protected axisFontFamilyProperty?: string;
private strokeThicknessProperty;
private strokeDashArrayProperty;
private strokeProperty;
private showLabelProperty;
private axisLabelStrokeProperty;
private axisLabelFillProperty;
private labelPlacementProperty;
private labelValueProperty;
private labelPaddingProperty;
private labelCornerRadiusProperty;
/**
* Create an instance of a LineAnnotation
* @param options Optional parameters of type {@link ILineAnnotationOptions} which configure the annotation upon construction
*/
constructor(options?: ILineAnnotationOptions);
/**
* Gets the stroke for the {@link LineAnnotation}
* @remarks Acceptable values include RGB format e.g. ```#FF0000```, RGBA format e.g. ```#FF000077`` and RGBA format e.g. ```rgba(255,0,0,0.5)```
*/
get stroke(): string;
/**
* Sets the stroke for the {@link LineAnnotation}
* @remarks Acceptable values include RGB format e.g. ```#FF0000```, RGBA format e.g. ```#FF000077`` and RGBA format e.g. ```rgba(255,0,0,0.5)```
*/
set stroke(htmlColorCode: string);
/**
* Gets the strokeThickness for the {@link LineAnnotation}
*/
get strokeThickness(): number;
/**
* Sets the strokeThickness for the {@link LineAnnotation}
*/
set strokeThickness(value: number);
/**
* Gets the strokeDashArray for the {@link LineAnnotation}
*/
get strokeDashArray(): number[];
/**
* Sets the strokeDashArray for the {@link LineAnnotation}
*/
set strokeDashArray(value: number[]);
/**
* Gets the showLabel for the {@link LineAnnotation}
*/
get showLabel(): boolean;
/**
* Sets the showLabel for the {@link LineAnnotation}
*/
set showLabel(value: boolean);
/**
* Gets the axisLabelStroke for the {@link LineAnnotation}
*/
get axisLabelStroke(): string;
/**
* Sets the axisLabelStroke for the {@link LineAnnotation}
*/
set axisLabelStroke(value: string);
/**
* Gets the axisLabelFill for the {@link LineAnnotation}
*/
get axisLabelFill(): string;
/**
* Sets the axisLabelFill for the {@link LineAnnotation}
*/
set axisLabelFill(value: string);
/**
* Gets the axisFontSize for the {@link LineAnnotation}
*/
get axisFontSize(): number;
/**
* Sets the axisFontSize for the {@link LineAnnotation}
*/
set axisFontSize(value: number);
/**
* Gets the axisFontSize for the {@link LineAnnotation}
*/
get axisFontFamily(): string;
/**
* Sets the axisFontSize for the {@link LineAnnotation}
*/
set axisFontFamily(value: string);
/**
* Gets the labelPlacement for the {@link LineAnnotation}
*/
get labelPlacement(): ELabelPlacement;
/**
* Sets the labelPlacement for the {@link LineAnnotation}
*/
set labelPlacement(value: ELabelPlacement);
/**
* Gets the labelValue for the {@link LineAnnotation}
*/
get labelValue(): string;
/**
* Sets the labelValue for the {@link LineAnnotation}
*/
set labelValue(value: string);
/**
* Gets or sets the extra padding (in pixels) applied to line annotation labels
*/
get labelPadding(): Thickness;
set labelPadding(value: Thickness);
/**
* Gets or sets the corner/border radius for the line annotation labels, in pixels
*/
get labelCornerRadius(): number;
set labelCornerRadius(value: number);
/** @inheritDoc */
delete(): void;
/** @inheritDoc */
onAttach(scs: SciChartSurface): void;
/** @inheritDoc */
drawWithContext(renderContext: WebGlRenderContext2D, xCalc: CoordinateCalculatorBase, yCalc: CoordinateCalculatorBase, seriesViewRect: Rect, surfaceViewRect: Rect, chartViewRect: Rect): void;
onDragStarted(args: ModifierMouseArgs): boolean;
calcDragDistance(xyValues: Point): void;
/**
* @instance
*/
onDpiChanged(args: TDpiChangedEventArgs): void;
toJSON(): {
type: EAnnotationType;
options: Required<Omit<IAnnotationBaseOptions, never>>;
};
protected checkIsClickedOnAnnotationInternal(x: number, y: number): boolean;
protected notifyPropertyChanged(propertyName: string): void;
protected updateAdornerInner(): void;
svgStringAdornerTemplate(x1: number, y1: number, x2: number, y2: number): string;
}