UNPKG

2.53 kBTypeScriptView Raw
1import { MappingDatum, Point } from '../../interface';
2import { LabelCfg, LabelItem, LabelPointCfg, TextAlign } from './interface';
3import Labels from '../../component/labels';
4import Geometry from '../base';
5export declare type GeometryLabelConstructor = new (cfg: any) => GeometryLabel;
6/**
7 * Geometry Label 基类,用于生成 Geometry 下所有 label 的配置项信息
8 */
9export default class GeometryLabel {
10 /** geometry 实例 */
11 readonly geometry: Geometry;
12 labelsRenderer: Labels;
13 /** 默认的布局 */
14 defaultLayout: string;
15 constructor(geometry: Geometry);
16 getLabelItems(mapppingArray: MappingDatum[]): LabelItem[];
17 render(mapppingArray: MappingDatum[], isUpdate?: boolean): void;
18 clear(): void;
19 destroy(): void;
20 getCoordinate(): import("@antv/coord/lib/coord/base").default;
21 /**
22 * 获取 label 的默认配置
23 */
24 protected getDefaultLabelCfg(offset?: number, position?: string): any;
25 /**
26 * 获取当前 label 的最终配置
27 * @param labelCfg
28 */
29 protected getThemedLabelCfg(labelCfg: LabelCfg): any;
30 /**
31 * 设置 label 位置
32 * @param labelPointCfg
33 * @param mappingData
34 * @param index
35 * @param position
36 */
37 protected setLabelPosition(labelPointCfg: LabelPointCfg, mappingData: MappingDatum, index: number, position: string): void;
38 /**
39 * @desc 获取 label offset
40 */
41 protected getLabelOffset(offset: number | string): number;
42 /**
43 * 获取每个 label 的偏移量 (矢量)
44 * @param labelCfg
45 * @param index
46 * @param total
47 * @return {Point} offsetPoint
48 */
49 protected getLabelOffsetPoint(labelCfg: LabelCfg, index: number, total: number): Point;
50 /**
51 * 获取每个 label 的位置
52 * @param labelCfg
53 * @param mappingData
54 * @param index
55 * @returns label point
56 */
57 protected getLabelPoint(labelCfg: LabelCfg, mappingData: MappingDatum, index: number): LabelPointCfg;
58 /**
59 * 获取文本的对齐方式
60 * @param item
61 * @param index
62 * @param total
63 * @returns
64 */
65 protected getLabelAlign(item: LabelItem, index: number, total: number): TextAlign;
66 /**
67 * 获取每一个 label 的唯一 id
68 * @param mappingData label 对应的图形的绘制数据
69 */
70 protected getLabelId(mappingData: MappingDatum): any;
71 private getLabelsRenderer;
72 private getLabelCfgs;
73 private getLabelText;
74 private getOffsetVector;
75 private getGeometryShapes;
76}