1 line
2.5 KiB
Plaintext
1 line
2.5 KiB
Plaintext
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/geometry/label/index.ts"],"names":[],"mappings":"AAeA,IAAM,mBAAmB,GAA6C,EAAE,CAAC;AACzE,IAAM,0BAA0B,GAA4C,EAAE,CAAC;AAE/E;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,mBAAmB,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,IAA8B;IAChF,mBAAmB,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,IAAI,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,OAAO,0BAA0B,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAAY,EAAE,QAAgC;IACxF,0BAA0B,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,QAAQ,CAAC;AAC5D,CAAC","sourcesContent":["import { BBox, IGroup, IShape } from '../../dependents';\nimport { LooseObject } from '../../interface';\nimport { GeometryLabelConstructor } from './base';\nimport { LabelItem } from './interface';\n\n/**\n * label 布局函数定义\n * @param items 存储每个 label 的详细信息\n * @param labels 所有的 labels 图形实例\n * @param shapes 所有 label 对应的图形元素实例\n * @param region 画布区域\n * @param cfg 用于存储各个布局函数开放给用户的配置数据\n */\ntype GeometryLabelsLayoutFn = (items: LabelItem[], labels: IGroup[], shapes: IShape[] | IGroup[], region: BBox, cfg?: LooseObject) => void;\n\nconst GEOMETRY_LABELS_MAP: Record<string, GeometryLabelConstructor> = {};\nconst GEOMETRY_LABELS_LAYOUT_MAP: Record<string, GeometryLabelsLayoutFn> = {};\n\n/**\n * 获取 `type` 对应的 [[GeometryLabel]] 类\n * @param type\n * @returns\n */\nexport function getGeometryLabel(type: string): GeometryLabelConstructor {\n return GEOMETRY_LABELS_MAP[type.toLowerCase()];\n}\n\n/**\n * 注册定义的 GeometryLabel 类\n * @param type GeometryLabel 类型名称\n * @param ctor GeometryLabel 类\n */\nexport function registerGeometryLabel(type: string, ctor: GeometryLabelConstructor) {\n GEOMETRY_LABELS_MAP[type.toLowerCase()] = ctor;\n}\n\n/**\n * 获取 `type` 对应的 [[GeometryLabelsLayoutFn]] label 布局函数\n * @param type 布局函数名称\n * @returns\n */\nexport function getGeometryLabelLayout(type: string): GeometryLabelsLayoutFn {\n return GEOMETRY_LABELS_LAYOUT_MAP[type.toLowerCase()];\n}\n\n/**\n * 注册定义的 label 布局函数\n * @param type label 布局函数名称\n * @param layoutFn label 布局函数\n */\nexport function registerGeometryLabelLayout(type: string, layoutFn: GeometryLabelsLayoutFn) {\n GEOMETRY_LABELS_LAYOUT_MAP[type.toLowerCase()] = layoutFn;\n}\n"]} |