ag-charts-community
Version:
Advanced Charting / Charts supporting Javascript / Typescript / React / Angular / Vue
95 lines (94 loc) • 3.28 kB
TypeScript
import { type FontOptions } from 'ag-charts-core';
import type { FontStyle, FontWeight, Opacity, Padding, PixelSize, TextOrSegments } from 'ag-charts-types';
import { BBox } from '../bbox';
import type { IScene, NodeOptions, RenderContext } from '../node';
import { type RotatableType, type TranslatableType } from '../transformable';
import { Shape, type ShapeColor } from './shape';
export interface TextSizeProperties extends FontOptions {
lineHeight?: number;
textAlign?: CanvasTextAlign;
textBaseline?: CanvasTextBaseline;
}
export interface TextBoxingProperties {
cornerRadius?: PixelSize;
padding?: Padding;
fill?: ShapeColor;
fillOpacity?: Opacity;
border?: {
enabled?: boolean;
stroke?: ShapeColor;
strokeWidth?: PixelSize;
strokeOpacity?: Opacity;
};
}
export declare class Text<D = unknown> extends Shape<D> {
static readonly className = "Text";
private static readonly debug;
private static readonly defaultFontSize;
private richText?;
private textMap?;
x: number;
y: number;
private lines;
private onTextChange;
text?: TextOrSegments;
fontCache?: string;
get font(): string;
resolveFont(): string | undefined;
fontStyle?: FontStyle;
fontWeight?: FontWeight;
fontSize: number;
fontFamily?: string;
textAlign: CanvasTextAlign;
textBaseline: CanvasTextBaseline;
lineHeight?: number;
private boxing?;
private boxPadding;
private readonly trimText;
constructor(options?: NodeOptions & {
trimText?: boolean;
});
static measureBBox(text: TextOrSegments, x: number, y: number, options: {
font: FontOptions;
lineHeight?: number;
textAlign?: CanvasTextAlign;
textBaseline?: CanvasTextBaseline;
}): BBox;
private static computeBBox;
private static calcTopOffset;
private static calcSegmentedTopOffset;
private static calcLeftOffset;
getBBox(): BBox;
protected computeBBox(): BBox;
getTextMeasureBBox(): BBox;
getPlainText(): string;
isPointInPath(x: number, y: number): boolean;
setScene(scene?: IScene): void;
private generateTextMap;
render(renderCtx: RenderContext): void;
markDirty(property?: string): void;
private renderText;
private renderBoxing;
protected executeFill(ctx: CanvasRenderingContext2D): void;
protected executeStroke(ctx: CanvasRenderingContext2D): void;
private renderLines;
setFont(props: FontOptions): void;
setAlign(props: {
textAlign: CanvasTextAlign;
textBaseline: CanvasTextBaseline;
}): void;
setBoxing(props: TextBoxingProperties): void;
hasBoxing(): boolean;
getBoxingProperties(): TextBoxingProperties;
toSVG(): {
elements: SVGElement[];
defs?: SVGElement[];
} | undefined;
private hasRenderableText;
}
export type RotatableText<D = unknown> = RotatableType<Text<D>>;
export type TransformableText<D = unknown> = RotatableType<TranslatableType<Text<D>>>;
type P = ConstructorParameters<typeof Text>[0];
export declare const RotatableText: new <D = unknown>(p?: P) => RotatableText<D>;
export declare const TransformableText: new <D = unknown>(p?: P) => TransformableText<D>;
export {};