scichart
Version:
Fast WebGL JavaScript Charting Library and Framework
142 lines (141 loc) • 5.56 kB
TypeScript
import { ELabelPlacement } from "../../../types/LabelPlacement";
import { ESurfaceType } from "../../../types/SurfaceType";
import { CoordinateCalculatorBase } from "../../Numerics/CoordinateCalculators/CoordinateCalculatorBase";
import { IAnnotationBaseOptions } from "./AnnotationBase";
import { IAdornerProvider } from "./IAdornerProvider";
import { EAnnotationType } from "./IAnnotation";
import { ISvgAnnotationBaseOptions, SvgAnnotationBase } from "./SvgAnnotationBase";
import { ILineAnnotation, ILineAnnotationOptions } from "./LineAnnotation";
import { Thickness } from "../../../Core/Thickness";
import { ModifierMouseArgs } from "../../ChartModifiers/ModifierMouseArgs";
import { Point } from "../../../Core/Point";
/**
* Options passed to the constructor of a {@link SvgLineAnnotation}
*/
export interface ISvgLineAnnotationOptions extends ILineAnnotationOptions, ISvgAnnotationBaseOptions {
}
/**
* @summary The {@link SvgLineAnnotation} is the SVG-only alternative to the {@link LineAnnotation} which draws a straight line between
* specific x1x2 y1y2 over the {@link SciChartSurface}
* @description
* To add a {@link SvgLineAnnotation} to a {@link SciChartSurface}, use the following code:
* ```ts
* const sciChartSurface: SciChartSurface;
* const lineAnnotation = new SvgLineAnnotation({ x1: 1, x2: 2, y1: 3, y2: 4, stroke: "#FF0000"});
* sciChartSurface.annotations.add(lineAnnotation);
* ```
* @remarks Used by default by {@link CursorModifier}, {@link RolloverModifier}, {@link VerticalSliceModifier} and moving the mouse will trigger an SVG-only layer render, which is cheaper than a full WebGL one
*/
export declare class SvgLineAnnotation extends SvgAnnotationBase implements ILineAnnotation, IAdornerProvider {
/** @inheritDoc */
readonly type: EAnnotationType;
/** @inheritDoc */
readonly surfaceTypes: ESurfaceType[];
private strokeProperty;
private strokeThicknessProperty;
private strokeDashArrayProperty;
private showLabelProperty;
private axisLabelStrokeProperty;
private axisLabelFillProperty;
private labelPlacementProperty;
private labelValueProperty;
private labelPaddingProperty;
private labelCornerRadiusProperty;
private lineEl?;
private labelsContainer?;
private labelCache;
protected axisFontSizeProperty: number;
protected axisFontFamilyProperty: string;
private static readonly DISTANCE_TO_LINE;
constructor(options?: ISvgLineAnnotationOptions);
/** @inheritDoc */
get stroke(): string;
/** @inheritDoc */
set stroke(htmlColorCode: string);
/** @inheritDoc */
get strokeThickness(): number;
/** @inheritDoc */
set strokeThickness(value: number);
/** @inheritDoc */
get strokeDashArray(): number[];
/** @inheritDoc */
set strokeDashArray(value: number[]);
/** @inheritDoc */
get showLabel(): boolean;
/** @inheritDoc */
set showLabel(value: boolean);
/** @inheritDoc */
get axisLabelStroke(): string;
/** @inheritDoc */
set axisLabelStroke(value: string);
/** @inheritDoc */
get axisLabelFill(): string;
/** @inheritDoc */
set axisLabelFill(value: string);
/** @inheritDoc */
get axisFontSize(): number;
/** @inheritDoc */
set axisFontSize(value: number);
/** @inheritDoc */
get axisFontFamily(): string;
/** @inheritDoc */
set axisFontFamily(value: string);
/** @inheritDoc */
get labelPlacement(): ELabelPlacement;
/** @inheritDoc */
set labelPlacement(value: ELabelPlacement);
/** @inheritDoc */
get labelValue(): string;
/** @inheritDoc */
set labelValue(value: string);
/** @inheritdoc */
get labelPadding(): Thickness;
set labelPadding(value: Thickness);
/** @inheritdoc */
get labelCornerRadius(): number;
set labelCornerRadius(value: number);
/** @inheritDoc */
create(xCalc: CoordinateCalculatorBase, yCalc: CoordinateCalculatorBase, xCoordSvgTrans: number, yCoordSvgTrans: number): void;
/** @inheritDoc */
update(xCalc: CoordinateCalculatorBase, yCalc: CoordinateCalculatorBase, xCoordSvgTrans: number, yCoordSvgTrans: number): void;
/**
* Mimics `AxisRenderer.drawModifiersAxisLabel` but for SVG
*/
private drawSvgAxisLabel;
getAnnotationBorders(): {
x1: number;
x2: number;
y1: number;
y2: number;
};
getAdornerAnnotationBorders(ordered?: boolean, applyDelta?: boolean): {
x1: number;
x2: number;
y1: number;
y2: number;
};
/**
* Generate SVG string for adorner (selection handles and line)
*/
svgStringAdornerTemplate(x1: number, y1: number, x2: number, y2: number): string;
/**
* Handle drag start - detect which point or body is being dragged
*/
onDragStarted(args: ModifierMouseArgs): boolean;
/**
* Calculate drag distance and update annotation coordinates
*/
calcDragDistance(xyValues: Point): void;
/**
* Check if click is on the annotation (for selection)
*/
protected checkIsClickedOnAnnotationInternal(x: number, y: number): boolean;
/** @inheritDoc */
protected notifyPropertyChanged(propertyName: string): void;
private updateLineStyle;
/** @inheritDoc */
toJSON(): {
type: EAnnotationType;
options: Required<Omit<IAnnotationBaseOptions, never>>;
};
}