@visactor/vrender-components 0.20.10-alpha.1 → 0.20.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -47,11 +47,11 @@ export function autoHide(labels, config) {
47
47
  do {
48
48
  items = reduce(items, sep);
49
49
  } while (items.length >= 3 && hasOverlap(items, sep));
50
- const shouldCheck = (length, visibility, checkLength = !0) => checkLength && length < 3 || visibility;
51
- let checkFirst = shouldCheck(items.length, config.firstVisible, !1);
52
- const checkLast = shouldCheck(items.length, config.lastVisible), firstSourceItem = source[0], lastSourceItem = last(source);
50
+ const shouldCheck = (length, visibility, checkLength = !0) => checkLength && length < 3 || visibility, checkFirst = shouldCheck(items.length, config.firstVisible, !1);
51
+ let checkLast = shouldCheck(items.length, config.lastVisible);
52
+ const firstSourceItem = source[0], lastSourceItem = last(source);
53
53
  intersect(firstSourceItem, lastSourceItem, sep) && checkFirst && checkLast && (lastSourceItem.setAttribute("opacity", 0),
54
- checkFirst = !1), forceItemVisible(firstSourceItem, items, checkFirst, (item => intersect(item, firstSourceItem, sep))),
54
+ checkLast = !1), forceItemVisible(firstSourceItem, items, checkFirst, (item => intersect(item, firstSourceItem, sep))),
55
55
  forceItemVisible(lastSourceItem, items, checkLast, (item => intersect(item, lastSourceItem, sep) || !(!checkFirst || item === firstSourceItem) && intersect(item, firstSourceItem, sep)), !0);
56
56
  }
57
57
  source.forEach((item => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/overlap/auto-hide.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,aAAa,IAAI,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEjE,MAAM,OAAO,GAAG;IACd,MAAM,EAAE,UAAU,KAAc;QAC9B,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,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H;IAED,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACpB,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC","file":"auto-hide.js","sourcesContent":["/**\n * @description 自动隐藏\n */\n\nimport { createRect, type IText } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { isEmpty, isFunction, last } from '@visactor/vutils';\nimport type { CustomMethod } from '../type';\nimport { textIntersect as intersect, hasOverlap } from '../util';\n\nconst methods = {\n parity: function (items: IText[]) {\n return items.filter((item, i) => (i % 2 ? item.setAttribute('opacity', 0) : 1));\n },\n greedy: function (items: IText[], sep: number) {\n let a: IText;\n return items.filter((b, i) => {\n if (!i || !intersect(a, b, sep)) {\n a = b;\n return 1;\n }\n return b.setAttribute('opacity', 0);\n });\n }\n};\n\nfunction hasBounds(item: IText) {\n let bounds;\n if (!item.OBBBounds.empty()) {\n bounds = item.OBBBounds;\n } else {\n bounds = item.AABBBounds;\n }\n return bounds.width() > 1 && bounds.height() > 1;\n}\n\n// reset all items to be fully opaque\nfunction reset(items: IText[]) {\n items.forEach(item => item.setAttribute('opacity', 1));\n return items;\n}\n\nfunction forceItemVisible(sourceItem: IText, items: IText[], check: boolean, comparator: any, inverse = false) {\n if (check && !sourceItem.attribute.opacity) {\n const remainLength = items.length;\n if (remainLength > 1) {\n sourceItem.setAttribute('opacity', 1);\n for (let i = 0; i < remainLength; i++) {\n const item = inverse ? items[remainLength - 1 - i] : items[i];\n if (comparator(item)) {\n item.setAttribute('opacity', 0);\n } else {\n break;\n }\n }\n }\n }\n}\n\ntype HideConfig = {\n /**\n * 轴的方向\n */\n orient: string;\n /**\n * 防重叠策略。\n * - 'parity': 奇偶校验,使用删除所有其他标签的策略(这对于标准线性轴非常有效)。\n * - 'greedy': 将执行标签的线性扫描,并删除与最后一个可见标签重叠的所有标签。\n * - 也可以传入函数用于自定义策略\n */\n method?: 'parity' | 'greedy' | CustomMethod;\n /**\n * 设置文本之间的间隔距离,单位 px\n */\n separation?: number;\n /**\n * 保证最后的label展示\n */\n lastVisible?: boolean;\n /**\n * 保证第一个的label展示\n */\n firstVisible?: boolean;\n};\n\nexport function autoHide(labels: IText[], config: HideConfig) {\n if (isEmpty(labels)) {\n return;\n }\n\n const source = labels.filter(hasBounds);\n if (isEmpty(source)) {\n return;\n }\n\n let items: IText[];\n\n items = reset(source);\n\n const { method = 'parity', separation: sep = 0 } = config;\n\n const reduce = isFunction(method) ? method : methods[method] || methods.parity;\n\n if (items.length >= 3 && hasOverlap(items, sep)) {\n do {\n items = reduce(items, sep);\n } while (items.length >= 3 && hasOverlap(items, sep));\n\n const shouldCheck = (length: number, visibility: boolean, checkLength: boolean = true) => {\n return checkLength ? length < 3 || visibility : visibility;\n };\n\n let checkFirst = shouldCheck(items.length, config.firstVisible, false);\n /**\n * 0.17.10 之前,当最后 label 个数小于 3 的时候,才做最后的label强制显示的策略\n */\n const checkLast = shouldCheck(items.length, config.lastVisible);\n\n const firstSourceItem = source[0];\n const lastSourceItem = last(source);\n\n if (intersect(firstSourceItem, lastSourceItem, sep) && checkFirst && checkLast) {\n lastSourceItem.setAttribute('opacity', 0); // Or firstSourceItem, depending on preference\n checkFirst = false;\n }\n\n forceItemVisible(firstSourceItem, items, checkFirst, (item: IText) => intersect(item, firstSourceItem, sep));\n\n forceItemVisible(\n lastSourceItem,\n items,\n checkLast,\n (item: IText) =>\n intersect(item, lastSourceItem, sep) ||\n (checkFirst && item !== firstSourceItem ? intersect(item, firstSourceItem, sep) : false),\n true\n );\n }\n\n source.forEach(item => {\n item.setAttribute('visible', !!item.attribute.opacity);\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/axis/overlap/auto-hide.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAA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,EAAE,GAAG,CAAC;YACpC,CAAC,UAAU,IAAI,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAC1F,IAAI,CACL,CAAC;KACH;IAED,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACpB,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC","file":"auto-hide.js","sourcesContent":["/**\n * @description 自动隐藏\n */\n\nimport { createRect, type IText } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { isEmpty, isFunction, last } from '@visactor/vutils';\nimport type { CustomMethod } from '../type';\nimport { textIntersect as intersect, hasOverlap } from '../util';\n\nconst methods = {\n parity: function (items: IText[]) {\n return items.filter((item, i) => (i % 2 ? item.setAttribute('opacity', 0) : 1));\n },\n greedy: function (items: IText[], sep: number) {\n let a: IText;\n return items.filter((b, i) => {\n if (!i || !intersect(a, b, sep)) {\n a = b;\n return 1;\n }\n return b.setAttribute('opacity', 0);\n });\n }\n};\n\nfunction hasBounds(item: IText) {\n let bounds;\n if (!item.OBBBounds.empty()) {\n bounds = item.OBBBounds;\n } else {\n bounds = item.AABBBounds;\n }\n return bounds.width() > 1 && bounds.height() > 1;\n}\n\n// reset all items to be fully opaque\nfunction reset(items: IText[]) {\n items.forEach(item => item.setAttribute('opacity', 1));\n return items;\n}\n\nfunction forceItemVisible(sourceItem: IText, items: IText[], check: boolean, comparator: any, inverse = false) {\n if (check && !sourceItem.attribute.opacity) {\n const remainLength = items.length;\n if (remainLength > 1) {\n sourceItem.setAttribute('opacity', 1);\n for (let i = 0; i < remainLength; i++) {\n const item = inverse ? items[remainLength - 1 - i] : items[i];\n if (comparator(item)) {\n item.setAttribute('opacity', 0);\n } else {\n break;\n }\n }\n }\n }\n}\n\ntype HideConfig = {\n /**\n * 轴的方向\n */\n orient: string;\n /**\n * 防重叠策略。\n * - 'parity': 奇偶校验,使用删除所有其他标签的策略(这对于标准线性轴非常有效)。\n * - 'greedy': 将执行标签的线性扫描,并删除与最后一个可见标签重叠的所有标签。\n * - 也可以传入函数用于自定义策略\n */\n method?: 'parity' | 'greedy' | CustomMethod;\n /**\n * 设置文本之间的间隔距离,单位 px\n */\n separation?: number;\n /**\n * 保证最后的label展示\n */\n lastVisible?: boolean;\n /**\n * 保证第一个的label展示\n */\n firstVisible?: boolean;\n};\n\nexport function autoHide(labels: IText[], config: HideConfig) {\n if (isEmpty(labels)) {\n return;\n }\n\n const source = labels.filter(hasBounds);\n if (isEmpty(source)) {\n return;\n }\n\n let items: IText[];\n\n items = reset(source);\n\n const { method = 'parity', separation: sep = 0 } = config;\n\n const reduce = isFunction(method) ? method : methods[method] || methods.parity;\n\n if (items.length >= 3 && hasOverlap(items, sep)) {\n do {\n items = reduce(items, sep);\n } while (items.length >= 3 && hasOverlap(items, sep));\n\n const shouldCheck = (length: number, visibility: boolean, checkLength: boolean = true) => {\n return checkLength ? length < 3 || visibility : visibility;\n };\n\n const checkFirst = shouldCheck(items.length, config.firstVisible, false);\n /**\n * 0.17.10 之前,当最后 label 个数小于 3 的时候,才做最后的label强制显示的策略\n */\n let checkLast = shouldCheck(items.length, config.lastVisible);\n\n const firstSourceItem = source[0];\n const lastSourceItem = last(source);\n\n if (intersect(firstSourceItem, lastSourceItem, sep) && checkFirst && checkLast) {\n lastSourceItem.setAttribute('opacity', 0); // Or firstSourceItem, depending on preference\n checkLast = false;\n }\n\n forceItemVisible(firstSourceItem, items, checkFirst, (item: IText) => intersect(item, firstSourceItem, sep));\n\n forceItemVisible(\n lastSourceItem,\n items,\n checkLast,\n (item: IText) =>\n intersect(item, lastSourceItem, sep) ||\n (checkFirst && item !== firstSourceItem ? intersect(item, firstSourceItem, sep) : false),\n true\n );\n }\n\n source.forEach(item => {\n item.setAttribute('visible', !!item.attribute.opacity);\n });\n}\n"]}
package/es/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "0.20.10-alpha.1";
1
+ export declare const version = "0.20.10";
2
2
  export * from './core/base';
3
3
  export * from './core/type';
4
4
  export * from './scrollbar';
package/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = "0.20.10-alpha.1";
1
+ export const version = "0.20.10";
2
2
 
3
3
  export * from "./core/base";
4
4
 
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAEzC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.20.10-alpha.1\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './util';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.20.10\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './util';\n"]}
@@ -2,9 +2,9 @@ import type { IGroup, IGraphic, IText, ILine, IRichText } from '@visactor/vrende
2
2
  import type { IAABBBounds, IBoundsLike, IPointLike } from '@visactor/vutils';
3
3
  import { AbstractComponent } from '../core/base';
4
4
  import type { PointLocationCfg } from '../core/type';
5
- import type { Bitmap } from './overlap';
5
+ import type { Bitmap, BitmapTool } from './overlap';
6
6
  import { bitmapTool } from './overlap';
7
- import type { BaseLabelAttrs, ILabelAnimation, LabelItem, ILabelEnterAnimation, ILabelExitAnimation, ILabelUpdateAnimation, LabelContent } from './type';
7
+ import type { BaseLabelAttrs, OverlapAttrs, ILabelAnimation, LabelItem, ILabelEnterAnimation, ILabelExitAnimation, ILabelUpdateAnimation, LabelContent } from './type';
8
8
  import type { ComponentOptions } from '../interface';
9
9
  export declare class LabelBase<T extends BaseLabelAttrs> extends AbstractComponent<T> {
10
10
  name: string;
@@ -49,6 +49,8 @@ export declare class LabelBase<T extends BaseLabelAttrs> extends AbstractCompone
49
49
  protected _initText(data?: LabelItem[]): (IText | IRichText)[];
50
50
  protected _layout(texts: (IText | IRichText)[]): (IText | IRichText)[];
51
51
  protected _overlapping(labels: (IText | IRichText)[]): (IRichText | IText)[];
52
+ protected _overlapGlobal(labels: (IText | IRichText)[], option: OverlapAttrs, bmpTool: BitmapTool, bitmap: Bitmap): (IRichText | IText)[];
53
+ protected _overlapByStrategy(labels: (IText | IRichText)[], option: OverlapAttrs, bmpTool: BitmapTool, bitmap: Bitmap): (IRichText | IText)[];
52
54
  protected getBaseMarkGroup(): IGroup;
53
55
  protected getGraphicBounds(graphic?: IGraphic, point?: Partial<PointLocationCfg>, position?: string): IBoundsLike;
54
56
  protected _renderLabels(labels: (IText | IRichText)[]): void;
package/es/label/base.js CHANGED
@@ -28,6 +28,8 @@ import { connectLineBetweenBounds, getPointsOfLineArea } from "./util";
28
28
 
29
29
  import { loadLabelComponent } from "./register";
30
30
 
31
+ import { shiftY } from "./overlap/shiftY";
32
+
31
33
  loadLabelComponent();
32
34
 
33
35
  export class LabelBase extends AbstractComponent {
@@ -203,15 +205,42 @@ export class LabelBase extends AbstractComponent {
203
205
  return texts;
204
206
  }
205
207
  _overlapping(labels) {
206
- var _a, _b, _c, _d;
208
+ var _a, _b, _c;
207
209
  if (0 === labels.length) return [];
208
- const option = isObject(this.attribute.overlap) ? this.attribute.overlap : {}, result = [], baseMarkGroup = this.getBaseMarkGroup(), size = null !== (_a = option.size) && void 0 !== _a ? _a : {
210
+ const option = isObject(this.attribute.overlap) ? this.attribute.overlap : {}, baseMarkGroup = this.getBaseMarkGroup(), size = null !== (_a = option.size) && void 0 !== _a ? _a : {
209
211
  width: null !== (_b = null == baseMarkGroup ? void 0 : baseMarkGroup.AABBBounds.width()) && void 0 !== _b ? _b : 0,
210
212
  height: null !== (_c = null == baseMarkGroup ? void 0 : baseMarkGroup.AABBBounds.height()) && void 0 !== _c ? _c : 0
211
213
  };
212
214
  if (0 === size.width || 0 === size.height) return labels;
213
- const {avoidBaseMark: avoidBaseMark, strategy: strategy = [], hideOnHit: hideOnHit = !0, clampForce: clampForce = !0, avoidMarks: avoidMarks = [], overlapPadding: overlapPadding} = option, bmpTool = this._bmpTool || bitmapTool(size.width, size.height), bitmap = this._bitmap || bmpTool.bitmap(), checkBounds = strategy.some((s => "bound" === s.type));
214
- avoidBaseMark && (null === (_d = this._baseMarks) || void 0 === _d || _d.forEach((mark => {
215
+ const {strategy: strategy, priority: priority} = option, bmpTool = this._bmpTool || bitmapTool(size.width, size.height), bitmap = this._bitmap || bmpTool.bitmap();
216
+ return priority && (labels = labels.sort(((a, b) => priority(b.attribute.data) - priority(a.attribute.data)))),
217
+ "shiftY" === (null == strategy ? void 0 : strategy.type) ? this._overlapGlobal(labels, option, bmpTool, bitmap) : this._overlapByStrategy(labels, option, bmpTool, bitmap);
218
+ }
219
+ _overlapGlobal(labels, option, bmpTool, bitmap) {
220
+ let result = labels.filter((label => label.attribute.visible && 0 !== label.attribute.opacity));
221
+ const {clampForce: clampForce = !0, hideOnHit: hideOnHit = !0, overlapPadding: overlapPadding, strategy: strategy} = option;
222
+ if (clampForce) for (let i = 0; i < result.length; i++) {
223
+ const text = labels[i], {dx: dx = 0, dy: dy = 0} = clampText(text, bmpTool.width, bmpTool.height);
224
+ 0 === dx && 0 === dy || text.setAttributes({
225
+ x: text.attribute.x + dx,
226
+ y: text.attribute.y + dy
227
+ });
228
+ }
229
+ result = shiftY(result, Object.assign({
230
+ maxY: bmpTool.height
231
+ }, strategy));
232
+ for (let i = 0; i < result.length; i++) {
233
+ const text = result[i], bounds = text.AABBBounds, range = boundToRange(bmpTool, bounds, !0);
234
+ canPlace(bmpTool, bitmap, bounds, clampForce, overlapPadding) ? bitmap.setRange(range) : hideOnHit ? text.setAttributes({
235
+ visible: !1
236
+ }) : bitmap.setRange(range);
237
+ }
238
+ return result;
239
+ }
240
+ _overlapByStrategy(labels, option, bmpTool, bitmap) {
241
+ var _a;
242
+ const {avoidBaseMark: avoidBaseMark, strategy: strategy = [], hideOnHit: hideOnHit = !0, clampForce: clampForce = !0, avoidMarks: avoidMarks = [], overlapPadding: overlapPadding} = option, result = [], checkBounds = strategy.some((s => "bound" === s.type));
243
+ avoidBaseMark && (null === (_a = this._baseMarks) || void 0 === _a || _a.forEach((mark => {
215
244
  mark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, mark.AABBBounds, !0));
216
245
  }))), avoidMarks.length > 0 && avoidMarks.forEach((avoid => {
217
246
  isString(avoid) ? getNoneGroupMarksByName(this.getRootNode(), avoid).forEach((avoidMark => {
@@ -219,7 +248,7 @@ export class LabelBase extends AbstractComponent {
219
248
  })) : avoid.AABBBounds && bitmap.setRange(boundToRange(bmpTool, avoid.AABBBounds, !0));
220
249
  }));
221
250
  for (let i = 0; i < labels.length; i++) {
222
- if (!1 === labels[i].visible) continue;
251
+ if (!1 === labels[i].attribute.visible) continue;
223
252
  const text = labels[i], baseMark = this.getRelatedGraphic(text.attribute);
224
253
  if (text.update(), !isRectIntersect(baseMark.AABBBounds, {
225
254
  x1: 0,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/label/base.ts"],"names":[],"mappings":";;;;;;;;;;;AAgBA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG9G,OAAO,EACL,UAAU,EACV,OAAO,EACP,OAAO,EACP,QAAQ,EACR,KAAK,EACL,eAAe,EACf,KAAK,EACL,OAAO,EACP,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChH,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1G,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAYjF,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACnG,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,kBAAkB,EAAE,CAAC;AACrB,MAAM,OAAO,SAAoC,SAAQ,iBAAoB;IA8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AAsB,EAAE,UAAuB;QACvE,IAAI,CAAC,SAAS,IAAI,CAAC,UAAU,EAAE;YAC7B,OAAO,KAAK,CAAC;SACd;QACD,OAAO,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IAED,WAAW,CAAC,KAAuB;QACjC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAChC,CAAC;IAED,eAAe;QACb,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAC/B,CAAC;;AA16BM,2BAAiB,GAA4B;IAClD,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QAIZ,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;QACtB,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KAChC;IACD,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,KAAK;CAChB,CAAC","file":"base.js","sourcesContent":["/**\n * @description Label 基类\n */\nimport type {\n IGroup,\n Text,\n IGraphic,\n IText,\n FederatedPointerEvent,\n IColor,\n ILine,\n IArea,\n IRichText,\n ILineGraphicAttribute\n} from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator, AttributeUpdateType, IContainPointMode, CustomPath2D } from '@visactor/vrender-core';\nimport type { IAABBBounds, IBoundsLike, IPointLike } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport {\n isFunction,\n isEmpty,\n isValid,\n isString,\n merge,\n isRectIntersect,\n isNil,\n isArray,\n isObject\n} from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { PointLocationCfg } from '../core/type';\nimport { labelSmartInvert, contrastAccessibilityChecker, smartInvertStrategy } from '../util/label-smartInvert';\nimport { createTextGraphicByType, getMarksByName, getNoneGroupMarksByName, traverseGroup } from '../util';\nimport { StateValue } from '../constant';\nimport type { Bitmap } from './overlap';\n// eslint-disable-next-line no-duplicate-imports\nimport { bitmapTool, boundToRange, canPlace, clampText, place } from './overlap';\nimport type {\n BaseLabelAttrs,\n OverlapAttrs,\n ILabelAnimation,\n LabelItem,\n SmartInvertAttrs,\n ILabelEnterAnimation,\n ILabelExitAnimation,\n ILabelUpdateAnimation,\n LabelContent\n} from './type';\nimport { DefaultLabelAnimation, getAnimationAttributes, updateAnimation } from './animate/animate';\nimport { connectLineBetweenBounds, getPointsOfLineArea } from './util';\nimport type { ComponentOptions } from '../interface';\nimport { loadLabelComponent } from './register';\n\nloadLabelComponent();\nexport class LabelBase<T extends BaseLabelAttrs> extends AbstractComponent<T> {\n name = 'label';\n\n protected _baseMarks?: IGraphic[];\n\n protected _isCollectionBase: boolean;\n\n protected _bitmap?: Bitmap;\n\n // parsed animation config\n protected _animationConfig?: {\n enter: ILabelEnterAnimation | false;\n exit: ILabelExitAnimation | false;\n update: ILabelUpdateAnimation | false;\n };\n\n static defaultAttributes: Partial<BaseLabelAttrs> = {\n textStyle: {\n fontSize: 12,\n // FIXME: we need a default color. Yet in current logic, textStyle will override fill from baseMark.\n // This need a new config option like `colorFull`\n // fill: '#000',\n textAlign: 'center',\n textBaseline: 'middle',\n boundsPadding: [-2, -1, -2, -1] // to ignore the textBound buf\n },\n offset: 0,\n pickable: false\n };\n\n setBitmap(bitmap: Bitmap) {\n this._bitmap = bitmap;\n }\n\n protected _bmpTool?: ReturnType<typeof bitmapTool>;\n setBitmapTool(bmpTool: ReturnType<typeof bitmapTool>) {\n this._bmpTool = bmpTool;\n }\n\n protected _graphicToText: Map<IGraphic, LabelContent>;\n\n protected _idToGraphic: Map<string, IGraphic>;\n\n protected _idToPoint: Map<string, IPointLike>;\n\n private _lastHover: IGraphic;\n private _lastSelect: IGraphic;\n\n private _enableAnimation: boolean;\n\n constructor(attributes: BaseLabelAttrs, options?: ComponentOptions) {\n const { data, ...restAttributes } = attributes;\n super(options?.skipDefault ? attributes : { data, ...merge({}, LabelBase.defaultAttributes, restAttributes) });\n }\n\n /**\n * 计算 text 的最终位置属性x, y\n * @param textBounds\n * @param graphicBounds\n * @param position\n * @param offset\n * @returns\n */\n protected labeling(\n textBounds: IBoundsLike,\n graphicBounds: IBoundsLike,\n position?: BaseLabelAttrs['position'],\n offset?: number\n ): { x: number; y: number } | undefined {\n // 基类没有指定的图元类型,需要在 data 中指定位置,故无需进行 labeling\n return;\n }\n\n protected _getLabelLinePoints(text: IText | IRichText, baseMark?: IGraphic) {\n return connectLineBetweenBounds(text.AABBBounds, baseMark?.AABBBounds);\n }\n\n protected _createLabelLine(text: IText | IRichText, baseMark?: IGraphic): ILine | undefined {\n const points = this._getLabelLinePoints(text, baseMark);\n if (points) {\n const lineGraphic = graphicCreator.line({\n points\n });\n\n const { line = {} } = text.attribute as any;\n\n if (line.customShape) {\n const customShape = line.customShape;\n lineGraphic.pathProxy = (attrs: Partial<ILineGraphicAttribute>) => {\n return customShape(\n {\n text,\n baseMark: baseMark\n },\n attrs,\n new CustomPath2D()\n );\n };\n }\n\n if (baseMark && baseMark.attribute.fill) {\n lineGraphic.setAttribute('stroke', baseMark.attribute.fill);\n }\n\n if (this.attribute.line && !isEmpty(this.attribute.line.style)) {\n lineGraphic.setAttributes(this.attribute.line.style);\n }\n this._setStatesOfLabelLine(lineGraphic);\n return lineGraphic;\n }\n }\n\n protected render() {\n this._prepare();\n if (isNil(this._idToGraphic) || (this._isCollectionBase && isNil(this._idToPoint))) {\n return;\n }\n\n const { overlap, smartInvert, dataFilter, customLayoutFunc, customOverlapFunc } = this.attribute;\n let data = this.attribute.data;\n\n if (isFunction(dataFilter)) {\n data = dataFilter(data);\n }\n\n let labels: (IText | IRichText)[] = this._initText(data);\n\n if (isFunction(customLayoutFunc)) {\n labels = customLayoutFunc(\n data,\n labels,\n this.getRelatedGraphic.bind(this),\n this._isCollectionBase ? (d: LabelItem) => this._idToPoint.get(d.id) : null\n );\n } else {\n // 根据关联图元和配置的position计算标签坐标\n labels = this._layout(labels);\n }\n\n if (isFunction(customOverlapFunc)) {\n labels = customOverlapFunc(\n labels as Text[],\n this.getRelatedGraphic.bind(this),\n this._isCollectionBase ? (d: LabelItem) => this._idToPoint.get(d.id) : null\n );\n } else {\n // 防重叠逻辑\n if (overlap !== false) {\n labels = this._overlapping(labels);\n }\n }\n\n if (isFunction(this.attribute.onAfterOverlapping)) {\n this.attribute.onAfterOverlapping(\n labels as Text[],\n this.getRelatedGraphic.bind(this),\n this._isCollectionBase ? (d: LabelItem) => this._idToPoint.get(d.id) : null\n );\n }\n\n if (labels && labels.length) {\n labels.forEach(label => {\n this._bindEvent(label);\n this._setStatesOfText(label);\n });\n }\n\n if (smartInvert !== false) {\n this._smartInvert(labels);\n }\n\n this._renderLabels(labels);\n }\n\n private _bindEvent(target: IGraphic) {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n if (!target) {\n return;\n }\n\n const { hover, select } = this.attribute;\n\n if (hover) {\n target.addEventListener('pointermove', this._onHover as EventListenerOrEventListenerObject);\n target.addEventListener('pointerout', this._onUnHover as EventListenerOrEventListenerObject);\n }\n\n if (select) {\n target.addEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n }\n }\n\n private _setStatesOfText(target: IGraphic) {\n if (!target) {\n return;\n }\n const state = this.attribute.state;\n\n if (!state || isEmpty(state)) {\n return;\n }\n\n target.states = state;\n }\n\n protected _setStatesOfLabelLine(target: IGraphic) {\n if (!target) {\n return;\n }\n const state = this.attribute.labelLineState;\n\n if (!state || isEmpty(state)) {\n return;\n }\n\n target.states = state;\n }\n\n private _onHover = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as IGraphic;\n if (target !== this._lastHover && !isEmpty(target.states)) {\n target.addState(StateValue.hover, true);\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (node !== target && !isEmpty(node.states)) {\n node.addState(StateValue.hoverReverse, true);\n }\n });\n this._lastHover = target;\n }\n };\n\n private _onUnHover = (e: FederatedPointerEvent) => {\n if (this._lastHover) {\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (!isEmpty(node.states)) {\n node.removeState(StateValue.hoverReverse);\n node.removeState(StateValue.hover);\n }\n });\n this._lastHover = null;\n }\n };\n\n private _onClick = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as IGraphic;\n if (this._lastSelect === target && target.hasState('selected')) {\n // 取消选中\n this._lastSelect = null;\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (!isEmpty(node.states)) {\n node.removeState(StateValue.selectedReverse);\n node.removeState(StateValue.selected);\n }\n });\n return;\n }\n\n if (!isEmpty(target.states)) {\n target.addState(StateValue.selected, true);\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (node !== target && !isEmpty(node.states)) {\n node.addState(StateValue.selectedReverse, true);\n }\n });\n this._lastSelect = target;\n }\n };\n\n protected _createLabelText(attributes: LabelItem) {\n const textAttrs = {\n ...this.stage?.getTheme()?.text,\n ...attributes\n };\n return createTextGraphicByType(textAttrs, 'textType');\n }\n\n private _prepare() {\n const currentBaseMarks: IGraphic[] = [];\n let baseMarks;\n if (isFunction(this.attribute.getBaseMarks)) {\n baseMarks = this.attribute.getBaseMarks();\n } else {\n baseMarks = getMarksByName(this.getRootNode() as IGroup, this.attribute.baseMarkGroupName);\n }\n\n baseMarks.forEach(mark => {\n if ((mark as any).releaseStatus !== 'willRelease') {\n currentBaseMarks.push(mark);\n }\n });\n\n this._idToGraphic?.clear();\n this._idToPoint?.clear();\n this._baseMarks = currentBaseMarks;\n this._isCollectionBase = this.attribute.type === 'line-data';\n\n if (!currentBaseMarks || currentBaseMarks.length === 0) {\n return;\n }\n\n const { data } = this.attribute;\n\n if (!data || data.length === 0) {\n return;\n }\n if (!this._idToGraphic) {\n this._idToGraphic = new Map();\n }\n\n // generate id mapping before data filter\n if (this._isCollectionBase) {\n if (!this._idToPoint) {\n this._idToPoint = new Map();\n }\n let cur = 0;\n for (let i = 0; i < currentBaseMarks.length; i++) {\n const baseMark = currentBaseMarks[i];\n const points = getPointsOfLineArea(baseMark as ILine | IArea);\n\n if (points && points.length) {\n for (let j = 0; j < points.length; j++) {\n const textData = data[cur];\n if (textData && points[j]) {\n if (!isValid(textData.id)) {\n textData.id = `vrender-component-${this.name}-${cur}`;\n }\n this._idToPoint.set(textData.id, points[j]);\n this._idToGraphic.set(textData.id, baseMark);\n }\n\n cur++;\n }\n }\n }\n } else {\n for (let i = 0; i < currentBaseMarks.length; i++) {\n const textData = data[i];\n const baseMark = currentBaseMarks[i] as IGraphic;\n if (textData && baseMark) {\n if (!isValid(textData.id)) {\n textData.id = `vrender-component-${this.name}-${i}`;\n }\n this._idToGraphic.set(textData.id, baseMark);\n }\n }\n }\n\n if (this.attribute.animation !== false) {\n const { animation, animationEnter, animationExit, animationUpdate } = this.attribute;\n const animationCfg = isObject(animation) ? animation : {};\n this._animationConfig = {\n enter: animationEnter !== false ? merge({}, DefaultLabelAnimation, animationCfg, animationEnter ?? {}) : false,\n exit: animationExit !== false ? merge({}, DefaultLabelAnimation, animationCfg, animationExit ?? {}) : false,\n update:\n animationUpdate !== false\n ? isArray(animationUpdate)\n ? animationUpdate\n : merge({}, DefaultLabelAnimation, animationCfg, animationUpdate ?? {})\n : false\n };\n } else {\n this._animationConfig = {\n enter: false,\n exit: false,\n update: false\n };\n }\n }\n\n protected getRelatedGraphic(item: LabelItem) {\n return this._idToGraphic.get(item.id);\n }\n\n protected _initText(data: LabelItem[] = []): (IText | IRichText)[] {\n const { textStyle = {} } = this.attribute;\n const labels = [];\n for (let i = 0; i < data.length; i++) {\n const textData = data[i];\n const baseMark = this.getRelatedGraphic(textData);\n if (!baseMark) {\n continue;\n }\n\n const labelAttribute = {\n fill: this._isCollectionBase\n ? isArray(baseMark.attribute.stroke)\n ? baseMark.attribute.stroke.find(entry => !!entry && entry !== true)\n : baseMark.attribute.stroke\n : baseMark.attribute.fill,\n ...textStyle,\n ...textData\n };\n const text = this._createLabelText(labelAttribute);\n labels.push(text);\n }\n\n return labels;\n }\n\n protected _layout(texts: (IText | IRichText)[]): (IText | IRichText)[] {\n const { position, offset } = this.attribute;\n for (let i = 0; i < texts.length; i++) {\n const text = texts[i];\n if (!text) {\n return;\n }\n const textData = text.attribute as LabelItem;\n const baseMark = this.getRelatedGraphic(textData);\n if (!baseMark) {\n continue;\n }\n\n text.attachedThemeGraphic = this as any;\n const textBounds = this.getGraphicBounds(text);\n text.attachedThemeGraphic = null;\n const actualPosition = isFunction(position) ? position(textData) : (position as string);\n\n const graphicBounds = this._isCollectionBase\n ? this.getGraphicBounds(null, this._idToPoint.get(textData.id), actualPosition)\n : this.getGraphicBounds(baseMark, { x: textData.x as number, y: textData.y as number }, actualPosition);\n\n const textLocation = this.labeling(textBounds, graphicBounds, actualPosition, offset);\n\n if (textLocation) {\n text.setAttributes(textLocation);\n }\n }\n\n return texts;\n }\n\n protected _overlapping(labels: (IText | IRichText)[]) {\n if (labels.length === 0) {\n return [];\n }\n const option = (isObject(this.attribute.overlap) ? this.attribute.overlap : {}) as OverlapAttrs;\n const result: (IText | IRichText)[] = [];\n const baseMarkGroup = this.getBaseMarkGroup();\n\n const size = option.size ?? {\n width: baseMarkGroup?.AABBBounds.width() ?? 0,\n height: baseMarkGroup?.AABBBounds.height() ?? 0\n };\n\n if (size.width === 0 || size.height === 0) {\n return labels;\n }\n\n const {\n avoidBaseMark,\n strategy = [],\n hideOnHit = true,\n clampForce = true,\n avoidMarks = [],\n overlapPadding\n } = option;\n const bmpTool = this._bmpTool || bitmapTool(size.width, size.height);\n const bitmap = this._bitmap || bmpTool.bitmap();\n const checkBounds = strategy.some(s => s.type === 'bound');\n\n // 躲避关联的基础图元\n if (avoidBaseMark) {\n this._baseMarks?.forEach(mark => {\n mark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, mark.AABBBounds, true));\n });\n }\n\n // 躲避指定图元\n if (avoidMarks.length > 0) {\n avoidMarks.forEach(avoid => {\n if (isString(avoid)) {\n getNoneGroupMarksByName(this.getRootNode() as IGroup, avoid).forEach(avoidMark => {\n avoidMark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, avoidMark.AABBBounds, true));\n });\n } else if (avoid.AABBBounds) {\n bitmap.setRange(boundToRange(bmpTool, avoid.AABBBounds, true));\n }\n });\n }\n\n for (let i = 0; i < labels.length; i++) {\n if (labels[i].visible === false) {\n continue;\n }\n\n const text = labels[i] as IText | IRichText;\n const baseMark = this.getRelatedGraphic(text.attribute);\n text.update();\n if (!isRectIntersect(baseMark.AABBBounds, { x1: 0, x2: bmpTool.width, y1: 0, y2: bmpTool.height }, true)) {\n continue;\n }\n\n // 默认位置可以放置\n if (canPlace(bmpTool, bitmap, text.AABBBounds, clampForce, overlapPadding)) {\n // 如果配置了限制在图形内部,需要提前判断;\n if (!checkBounds) {\n bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));\n result.push(text);\n continue;\n }\n\n if (\n checkBounds &&\n baseMark &&\n baseMark.AABBBounds &&\n this._canPlaceInside(text.AABBBounds, baseMark.AABBBounds)\n ) {\n bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));\n result.push(text);\n continue;\n }\n }\n\n let hasPlace: ReturnType<typeof place> = false;\n // 发生碰撞,根据策略寻找可放置的位置\n for (let j = 0; j < strategy.length; j++) {\n hasPlace = place(\n bmpTool,\n bitmap,\n strategy[j],\n <BaseLabelAttrs>this.attribute,\n text as Text,\n this._isCollectionBase\n ? this.getGraphicBounds(null, this._idToPoint.get((labels[i].attribute as any).id))\n : this.getGraphicBounds(baseMark, labels[i].attribute),\n this.labeling\n );\n if (hasPlace !== false) {\n text.setAttributes({ x: hasPlace.x, y: hasPlace.y });\n result.push(text);\n break;\n }\n }\n\n // 尝试向内挤压\n if (!hasPlace && clampForce) {\n // 向内挤压不考虑 overlapPadding\n const { dx = 0, dy = 0 } = clampText(text as IText, bmpTool.width, bmpTool.height);\n if (dx === 0 && dy === 0) {\n if (canPlace(bmpTool, bitmap, text.AABBBounds)) {\n // xy方向偏移都为0,意味着不考虑 overlapPadding 时,实际上可以放得下\n bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));\n result.push(text);\n continue;\n }\n } else if (\n canPlace(\n bmpTool,\n bitmap,\n {\n x1: text.AABBBounds.x1 + dx,\n x2: text.AABBBounds.x2 + dx,\n y1: text.AABBBounds.y1 + dy,\n y2: text.AABBBounds.y2 + dy\n }\n // 向内 clamp 只处理超出的位移量,不叠加 overlapPadding\n )\n ) {\n text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });\n bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));\n result.push(text);\n continue;\n }\n }\n\n !hasPlace && !hideOnHit && result.push(text);\n }\n\n return result;\n }\n\n protected getBaseMarkGroup() {\n const { baseMarkGroupName } = this.attribute as BaseLabelAttrs;\n if (!baseMarkGroupName) {\n return;\n }\n return (this.getRootNode() as IGroup).find(node => node.name === baseMarkGroupName, true) as IGroup;\n }\n\n protected getGraphicBounds(graphic?: IGraphic, point?: Partial<PointLocationCfg>, position?: string): IBoundsLike;\n protected getGraphicBounds(graphic?: IGraphic, point: Partial<PointLocationCfg> = {}): IBoundsLike {\n if (graphic) {\n if (graphic.attribute.visible !== false) {\n return graphic.AABBBounds;\n }\n const { x, y } = graphic.attribute;\n return { x1: x, x2: x, y1: y, y2: y } as IBoundsLike;\n }\n const { x, y } = point;\n return { x1: x, x2: x, y1: y, y2: y } as IBoundsLike;\n }\n\n protected _renderLabels(labels: (IText | IRichText)[]) {\n const { syncState } = this.attribute;\n const currentTextMap: Map<any, LabelContent> = new Map();\n const prevTextMap: Map<any, LabelContent> = this._graphicToText || new Map();\n const texts = [] as (IText | IRichText)[];\n const labelLines = [] as ILine[];\n const { visible: showLabelLine } = this.attribute.line ?? {};\n\n labels &&\n labels.forEach((text, index) => {\n const relatedGraphic = this.getRelatedGraphic(text.attribute);\n const textKey = this._isCollectionBase ? (text.attribute as LabelItem).id : relatedGraphic;\n const state = prevTextMap?.get(textKey) ? 'update' : 'enter';\n let labelLine;\n if (showLabelLine) {\n labelLine = this._createLabelLine(text as IText, relatedGraphic);\n }\n if (syncState) {\n this.updateStatesOfLabels([labelLine ? { text, labelLine } : { text }], relatedGraphic.currentStates ?? []);\n }\n\n if (state === 'enter') {\n texts.push(text);\n currentTextMap.set(textKey, labelLine ? { text, labelLine } : { text });\n this._addLabel({ text, labelLine }, texts, labelLines, index);\n } else if (state === 'update') {\n const prevLabel = prevTextMap.get(textKey);\n prevTextMap.delete(textKey);\n currentTextMap.set(textKey, prevLabel);\n this._updateLabel(prevLabel, { text, labelLine });\n }\n });\n\n this._removeLabel(prevTextMap);\n\n this._graphicToText = currentTextMap;\n }\n\n protected _addLabel(\n label: LabelContent,\n texts?: LabelContent['text'][],\n labelLines?: LabelContent['labelLine'][],\n index?: number\n ) {\n const { text, labelLine } = label;\n // TODO: 或许还需要判断关联图元是否有动画?\n const relatedGraphic = this.getRelatedGraphic(text.attribute);\n this._syncStateWithRelatedGraphic(relatedGraphic);\n\n if (this._enableAnimation !== false && this._animationConfig.enter !== false) {\n if (relatedGraphic) {\n const { from, to } = getAnimationAttributes(text.attribute, 'fadeIn');\n if (text) {\n this.add(text);\n }\n\n if (labelLine) {\n labelLines.push(labelLine);\n this.add(labelLine);\n }\n\n // enter的时长如果不是大于0,那么直接跳过动画\n this._animationConfig.enter.duration > 0 &&\n relatedGraphic.once('animate-bind', a => {\n // text和labelLine共用一个from\n text.setAttributes(from);\n labelLine && labelLine.setAttributes(from);\n const listener = this._afterRelatedGraphicAttributeUpdate(\n text,\n texts,\n labelLine,\n labelLines,\n index,\n relatedGraphic,\n to,\n this._animationConfig.enter as ILabelEnterAnimation\n );\n relatedGraphic.on('afterAttributeUpdate', listener);\n });\n }\n } else {\n if (text) {\n this.add(text);\n }\n if (labelLine) {\n this.add(labelLine);\n }\n }\n }\n\n protected _updateLabel(prevLabel: LabelContent, currentLabel: LabelContent) {\n const { text: prevText, labelLine: prevLabelLine } = prevLabel;\n const { text: curText, labelLine: curLabelLine } = currentLabel;\n if (this._enableAnimation !== false && this._animationConfig.update !== false) {\n const { duration, easing } = this._animationConfig.update;\n updateAnimation(prevText, curText, this._animationConfig.update);\n if (prevLabelLine && curLabelLine) {\n prevLabel.labelLine.animate().to(curLabelLine.attribute, duration, easing);\n }\n } else {\n prevLabel.text.setAttributes(curText.attribute as any);\n if (prevLabelLine && curLabelLine) {\n prevLabel.labelLine.setAttributes(curLabelLine.attribute);\n }\n }\n }\n\n protected _removeLabel(textMap: Map<any, LabelContent>) {\n const removeLabelAndLine = (label: LabelContent) => {\n this.removeChild(label.text);\n if (label.labelLine) {\n this.removeChild(label.labelLine);\n }\n };\n\n if (this._enableAnimation !== false && this._animationConfig.exit !== false) {\n const { duration, easing } = this._animationConfig.exit;\n textMap.forEach(label => {\n label.text\n ?.animate()\n .to(getAnimationAttributes(label.text.attribute, 'fadeOut').to, duration, easing)\n .onEnd(() => {\n removeLabelAndLine(label);\n });\n });\n } else {\n textMap.forEach(label => {\n removeLabelAndLine(label);\n });\n }\n }\n\n private updateStatesOfLabels(labels: LabelContent[], currentStates?: string[]) {\n labels.forEach(label => {\n if (label) {\n if (label.text) {\n label.text.useStates(currentStates);\n }\n\n if (label.labelLine) {\n label.labelLine.useStates(currentStates);\n }\n }\n });\n }\n\n protected _handleRelatedGraphicSetState = (e: any) => {\n if (\n e.detail?.type === AttributeUpdateType.STATE ||\n (e.detail?.type === AttributeUpdateType.ANIMATE_UPDATE && e.detail.animationState?.isFirstFrameOfStep)\n ) {\n const currentStates = e.target?.currentStates ?? [];\n const labels = this._isCollectionBase ? [...this._graphicToText.values()] : [this._graphicToText.get(e.target)];\n\n this.updateStatesOfLabels(labels, currentStates);\n }\n };\n\n protected _syncStateWithRelatedGraphic(relatedGraphic: IGraphic) {\n if (this.attribute.syncState && relatedGraphic) {\n relatedGraphic.on('afterAttributeUpdate', this._handleRelatedGraphicSetState);\n }\n }\n\n // 默认labelLine和text共用相同动画属性\n protected _afterRelatedGraphicAttributeUpdate(\n text: IText | IRichText,\n texts: (IText | IRichText)[],\n labelLine: ILine,\n labelLines: ILine[],\n index: number,\n relatedGraphic: IGraphic,\n to: any,\n { mode, duration, easing, delay }: ILabelAnimation\n ) {\n // TODO: 跟随动画\n const listener = (event: any) => {\n const { detail } = event;\n if (!detail) {\n return {};\n }\n const step = detail.animationState?.step;\n const isValidAnimateState =\n detail.type === AttributeUpdateType.ANIMATE_UPDATE &&\n step &&\n // 不是第一个wait\n !(step.type === 'wait' && step.prev?.type == null);\n\n if (!isValidAnimateState) {\n return {};\n }\n // const prevStep = step.prev;\n // if (prevStep && prevStep.type === 'wait' && prevStep.prev?.type == null) {\n // delay = delay ?? step.position;\n // }\n if (detail.type === AttributeUpdateType.ANIMATE_END) {\n text.setAttributes(to);\n labelLine && labelLine.setAttributes(to);\n return;\n }\n\n const onStart = () => {\n if (relatedGraphic) {\n relatedGraphic.onAnimateBind = undefined;\n relatedGraphic.removeEventListener('afterAttributeUpdate', listener);\n }\n };\n\n switch (mode) {\n case 'after':\n // 3. 当前关联图元的动画播放结束后\n if (detail.animationState.end) {\n text.animate({ onStart }).wait(delay).to(to, duration, easing);\n labelLine && labelLine.animate().wait(delay).to(to, duration, easing);\n }\n break;\n case 'after-all':\n // 2. 所有完成后才开始;\n if (index === texts.length - 1) {\n if (detail.animationState.end) {\n texts.forEach(t => {\n t.animate({ onStart }).wait(delay).to(to, duration, easing);\n });\n labelLines.forEach(t => {\n t.animate().wait(delay).to(to, duration, easing);\n });\n }\n }\n break;\n case 'same-time':\n default:\n if (this._isCollectionBase) {\n const point = this._idToPoint.get((text.attribute as LabelItem).id);\n if (\n point &&\n (!text.animates || !text.animates.has('label-animate')) &&\n relatedGraphic.containsPoint(point.x, point.y, IContainPointMode.LOCAL, this.stage?.getPickerService())\n ) {\n text.animate({ onStart }).wait(delay).to(to, duration, easing);\n labelLine && labelLine.animate().wait(delay).to(to, duration, easing);\n }\n } else if (detail.animationState.isFirstFrameOfStep) {\n text.animate({ onStart }).wait(delay).to(to, duration, easing);\n labelLine && labelLine.animate().wait(delay).to(to, duration, easing);\n }\n\n break;\n }\n };\n return listener;\n }\n\n protected _smartInvert(labels: (IText | IRichText)[]) {\n const option = (isObject(this.attribute.smartInvert) ? this.attribute.smartInvert : {}) as SmartInvertAttrs;\n const { textType, contrastRatiosThreshold, alternativeColors, mode, interactInvertType } = option;\n const fillStrategy = option.fillStrategy ?? 'invertBase';\n const strokeStrategy = option.strokeStrategy ?? 'base';\n const brightColor = option.brightColor ?? '#ffffff';\n const darkColor = option.darkColor ?? '#000000';\n const outsideEnable = option.outsideEnable ?? false;\n\n if (fillStrategy === 'null' && strokeStrategy === 'null') {\n return;\n }\n\n for (let i = 0; i < labels.length; i++) {\n const label = labels[i];\n if (!label) {\n continue;\n }\n\n const baseMark = this.getRelatedGraphic(label.attribute as LabelItem);\n\n /**\n * 增加smartInvert时fillStrategy和 strokeStrategy的四种策略:\n * base(baseMark色),\n * inverBase(执行智能反色),\n * similarBase(智能反色的补色),\n * null(不执行智能反色,保持fill设置的颜色)\n * */\n const backgroundColor = baseMark.attribute.fill as IColor;\n const foregroundColor = label.attribute.fill as IColor;\n const invertColor = labelSmartInvert(\n foregroundColor,\n backgroundColor,\n textType,\n contrastRatiosThreshold,\n alternativeColors,\n mode\n );\n const similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;\n const isInside = this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds);\n const isIntersect =\n !isInside && label.AABBBounds && baseMark.AABBBounds && baseMark.AABBBounds.intersects(label.AABBBounds);\n\n if (isInside || outsideEnable || (isIntersect && interactInvertType === 'inside')) {\n // 按照标签展示在柱子内部的情况,执行反色逻辑\n const fill = smartInvertStrategy(fillStrategy, backgroundColor, invertColor, similarColor);\n fill && label.setAttributes({ fill });\n\n if (label.attribute.lineWidth === 0 || label.attribute.strokeOpacity === 0) {\n continue;\n }\n\n const stroke = smartInvertStrategy(strokeStrategy, backgroundColor, invertColor, similarColor);\n stroke && label.setAttributes({ stroke });\n } else if (isIntersect && interactInvertType !== 'none') {\n // 存在相交的情况\n /** 当label无法设置stroke时,不进行反色计算(容易反色为白色与白色背景混合不可见) */\n if (label.attribute.lineWidth === 0 || label.attribute.strokeOpacity === 0) {\n continue;\n }\n /** 当label设置stroke时,保留stroke设置的颜色,根据stroke对fill做反色 */\n if (label.attribute.stroke) {\n // stroke 作为背景色进行反色计算\n label.setAttributes({\n fill: labelSmartInvert(\n label.attribute.fill as IColor,\n label.attribute.stroke as IColor,\n textType,\n contrastRatiosThreshold,\n alternativeColors,\n mode\n )\n });\n continue;\n }\n /** 当label未设置stroke,且可设置stroke时,正常计算 */\n const fill = smartInvertStrategy(fillStrategy, backgroundColor, invertColor, similarColor);\n fill && label.setAttributes({ fill });\n\n const stroke = smartInvertStrategy(strokeStrategy, backgroundColor, invertColor, similarColor);\n stroke && label.setAttributes({ stroke });\n }\n }\n }\n\n /**\n * 是否在图形内部\n * @param textBound\n * @param shapeBound\n * @returns\n */\n protected _canPlaceInside(textBound: IBoundsLike, shapeBound: IAABBBounds) {\n if (!textBound || !shapeBound) {\n return false;\n }\n return shapeBound.encloses(textBound);\n }\n\n setLocation(point: PointLocationCfg) {\n this.translateTo(point.x, point.y);\n }\n\n disableAnimation() {\n this._enableAnimation = false;\n }\n\n enableAnimation() {\n this._enableAnimation = true;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/label/base.ts"],"names":[],"mappings":";;;;;;;;;;;AAgBA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG9G,OAAO,EACL,UAAU,EACV,OAAO,EACP,OAAO,EACP,QAAQ,EACR,KAAK,EACL,eAAe,EACf,KAAK,EACL,OAAO,EACP,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,M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["/**\n * @description Label 基类\n */\nimport type {\n IGroup,\n Text,\n IGraphic,\n IText,\n FederatedPointerEvent,\n IColor,\n ILine,\n IArea,\n IRichText,\n ILineGraphicAttribute\n} from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator, AttributeUpdateType, IContainPointMode, CustomPath2D } from '@visactor/vrender-core';\nimport type { IAABBBounds, IBoundsLike, IPointLike } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport {\n isFunction,\n isEmpty,\n isValid,\n isString,\n merge,\n isRectIntersect,\n isNil,\n isArray,\n isObject\n} from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { PointLocationCfg } from '../core/type';\nimport { labelSmartInvert, contrastAccessibilityChecker, smartInvertStrategy } from '../util/label-smartInvert';\nimport { createTextGraphicByType, getMarksByName, getNoneGroupMarksByName, traverseGroup } from '../util';\nimport { StateValue } from '../constant';\nimport type { Bitmap, BitmapTool } from './overlap';\n// eslint-disable-next-line no-duplicate-imports\nimport { bitmapTool, boundToRange, canPlace, clampText, place } from './overlap';\nimport type {\n BaseLabelAttrs,\n OverlapAttrs,\n ILabelAnimation,\n LabelItem,\n SmartInvertAttrs,\n ILabelEnterAnimation,\n ILabelExitAnimation,\n ILabelUpdateAnimation,\n LabelContent,\n ShiftYStrategy,\n Strategy\n} from './type';\nimport { DefaultLabelAnimation, getAnimationAttributes, updateAnimation } from './animate/animate';\nimport { connectLineBetweenBounds, getPointsOfLineArea } from './util';\nimport type { ComponentOptions } from '../interface';\nimport { loadLabelComponent } from './register';\nimport { shiftY } from './overlap/shiftY';\n\nloadLabelComponent();\nexport class LabelBase<T extends BaseLabelAttrs> extends AbstractComponent<T> {\n name = 'label';\n\n protected _baseMarks?: IGraphic[];\n\n protected _isCollectionBase: boolean;\n\n protected _bitmap?: Bitmap;\n\n // parsed animation config\n protected _animationConfig?: {\n enter: ILabelEnterAnimation | false;\n exit: ILabelExitAnimation | false;\n update: ILabelUpdateAnimation | false;\n };\n\n static defaultAttributes: Partial<BaseLabelAttrs> = {\n textStyle: {\n fontSize: 12,\n // FIXME: we need a default color. Yet in current logic, textStyle will override fill from baseMark.\n // This need a new config option like `colorFull`\n // fill: '#000',\n textAlign: 'center',\n textBaseline: 'middle',\n boundsPadding: [-2, -1, -2, -1] // to ignore the textBound buf\n },\n offset: 0,\n pickable: false\n };\n\n setBitmap(bitmap: Bitmap) {\n this._bitmap = bitmap;\n }\n\n protected _bmpTool?: ReturnType<typeof bitmapTool>;\n setBitmapTool(bmpTool: ReturnType<typeof bitmapTool>) {\n this._bmpTool = bmpTool;\n }\n\n protected _graphicToText: Map<IGraphic, LabelContent>;\n\n protected _idToGraphic: Map<string, IGraphic>;\n\n protected _idToPoint: Map<string, IPointLike>;\n\n private _lastHover: IGraphic;\n private _lastSelect: IGraphic;\n\n private _enableAnimation: boolean;\n\n constructor(attributes: BaseLabelAttrs, options?: ComponentOptions) {\n const { data, ...restAttributes } = attributes;\n super(options?.skipDefault ? attributes : { data, ...merge({}, LabelBase.defaultAttributes, restAttributes) });\n }\n\n /**\n * 计算 text 的最终位置属性x, y\n * @param textBounds\n * @param graphicBounds\n * @param position\n * @param offset\n * @returns\n */\n protected labeling(\n textBounds: IBoundsLike,\n graphicBounds: IBoundsLike,\n position?: BaseLabelAttrs['position'],\n offset?: number\n ): { x: number; y: number } | undefined {\n // 基类没有指定的图元类型,需要在 data 中指定位置,故无需进行 labeling\n return;\n }\n\n protected _getLabelLinePoints(text: IText | IRichText, baseMark?: IGraphic) {\n return connectLineBetweenBounds(text.AABBBounds, baseMark?.AABBBounds);\n }\n\n protected _createLabelLine(text: IText | IRichText, baseMark?: IGraphic): ILine | undefined {\n const points = this._getLabelLinePoints(text, baseMark);\n if (points) {\n const lineGraphic = graphicCreator.line({\n points\n });\n\n const { line = {} } = text.attribute as any;\n\n if (line.customShape) {\n const customShape = line.customShape;\n lineGraphic.pathProxy = (attrs: Partial<ILineGraphicAttribute>) => {\n return customShape(\n {\n text,\n baseMark: baseMark\n },\n attrs,\n new CustomPath2D()\n );\n };\n }\n\n if (baseMark && baseMark.attribute.fill) {\n lineGraphic.setAttribute('stroke', baseMark.attribute.fill);\n }\n\n if (this.attribute.line && !isEmpty(this.attribute.line.style)) {\n lineGraphic.setAttributes(this.attribute.line.style);\n }\n this._setStatesOfLabelLine(lineGraphic);\n return lineGraphic;\n }\n }\n\n protected render() {\n this._prepare();\n if (isNil(this._idToGraphic) || (this._isCollectionBase && isNil(this._idToPoint))) {\n return;\n }\n\n const { overlap, smartInvert, dataFilter, customLayoutFunc, customOverlapFunc } = this.attribute;\n let data = this.attribute.data;\n\n if (isFunction(dataFilter)) {\n data = dataFilter(data);\n }\n\n let labels: (IText | IRichText)[] = this._initText(data);\n\n if (isFunction(customLayoutFunc)) {\n labels = customLayoutFunc(\n data,\n labels,\n this.getRelatedGraphic.bind(this),\n this._isCollectionBase ? (d: LabelItem) => this._idToPoint.get(d.id) : null\n );\n } else {\n // 根据关联图元和配置的position计算标签坐标\n labels = this._layout(labels);\n }\n\n if (isFunction(customOverlapFunc)) {\n labels = customOverlapFunc(\n labels as Text[],\n this.getRelatedGraphic.bind(this),\n this._isCollectionBase ? (d: LabelItem) => this._idToPoint.get(d.id) : null\n );\n } else {\n // 防重叠逻辑\n if (overlap !== false) {\n labels = this._overlapping(labels);\n }\n }\n\n if (isFunction(this.attribute.onAfterOverlapping)) {\n this.attribute.onAfterOverlapping(\n labels as Text[],\n this.getRelatedGraphic.bind(this),\n this._isCollectionBase ? (d: LabelItem) => this._idToPoint.get(d.id) : null\n );\n }\n\n if (labels && labels.length) {\n labels.forEach(label => {\n this._bindEvent(label);\n this._setStatesOfText(label);\n });\n }\n\n if (smartInvert !== false) {\n this._smartInvert(labels);\n }\n\n this._renderLabels(labels);\n }\n\n private _bindEvent(target: IGraphic) {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n if (!target) {\n return;\n }\n\n const { hover, select } = this.attribute;\n\n if (hover) {\n target.addEventListener('pointermove', this._onHover as EventListenerOrEventListenerObject);\n target.addEventListener('pointerout', this._onUnHover as EventListenerOrEventListenerObject);\n }\n\n if (select) {\n target.addEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n }\n }\n\n private _setStatesOfText(target: IGraphic) {\n if (!target) {\n return;\n }\n const state = this.attribute.state;\n\n if (!state || isEmpty(state)) {\n return;\n }\n\n target.states = state;\n }\n\n protected _setStatesOfLabelLine(target: IGraphic) {\n if (!target) {\n return;\n }\n const state = this.attribute.labelLineState;\n\n if (!state || isEmpty(state)) {\n return;\n }\n\n target.states = state;\n }\n\n private _onHover = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as IGraphic;\n if (target !== this._lastHover && !isEmpty(target.states)) {\n target.addState(StateValue.hover, true);\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (node !== target && !isEmpty(node.states)) {\n node.addState(StateValue.hoverReverse, true);\n }\n });\n this._lastHover = target;\n }\n };\n\n private _onUnHover = (e: FederatedPointerEvent) => {\n if (this._lastHover) {\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (!isEmpty(node.states)) {\n node.removeState(StateValue.hoverReverse);\n node.removeState(StateValue.hover);\n }\n });\n this._lastHover = null;\n }\n };\n\n private _onClick = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as IGraphic;\n if (this._lastSelect === target && target.hasState('selected')) {\n // 取消选中\n this._lastSelect = null;\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (!isEmpty(node.states)) {\n node.removeState(StateValue.selectedReverse);\n node.removeState(StateValue.selected);\n }\n });\n return;\n }\n\n if (!isEmpty(target.states)) {\n target.addState(StateValue.selected, true);\n traverseGroup(this as unknown as IGraphic, (node: IGraphic) => {\n if (node !== target && !isEmpty(node.states)) {\n node.addState(StateValue.selectedReverse, true);\n }\n });\n this._lastSelect = target;\n }\n };\n\n protected _createLabelText(attributes: LabelItem) {\n const textAttrs = {\n ...this.stage?.getTheme()?.text,\n ...attributes\n };\n return createTextGraphicByType(textAttrs, 'textType');\n }\n\n private _prepare() {\n const currentBaseMarks: IGraphic[] = [];\n let baseMarks;\n if (isFunction(this.attribute.getBaseMarks)) {\n baseMarks = this.attribute.getBaseMarks();\n } else {\n baseMarks = getMarksByName(this.getRootNode() as IGroup, this.attribute.baseMarkGroupName);\n }\n\n baseMarks.forEach(mark => {\n if ((mark as any).releaseStatus !== 'willRelease') {\n currentBaseMarks.push(mark);\n }\n });\n\n this._idToGraphic?.clear();\n this._idToPoint?.clear();\n this._baseMarks = currentBaseMarks;\n this._isCollectionBase = this.attribute.type === 'line-data';\n\n if (!currentBaseMarks || currentBaseMarks.length === 0) {\n return;\n }\n\n const { data } = this.attribute;\n\n if (!data || data.length === 0) {\n return;\n }\n if (!this._idToGraphic) {\n this._idToGraphic = new Map();\n }\n\n // generate id mapping before data filter\n if (this._isCollectionBase) {\n if (!this._idToPoint) {\n this._idToPoint = new Map();\n }\n let cur = 0;\n for (let i = 0; i < currentBaseMarks.length; i++) {\n const baseMark = currentBaseMarks[i];\n const points = getPointsOfLineArea(baseMark as ILine | IArea);\n\n if (points && points.length) {\n for (let j = 0; j < points.length; j++) {\n const textData = data[cur];\n if (textData && points[j]) {\n if (!isValid(textData.id)) {\n textData.id = `vrender-component-${this.name}-${cur}`;\n }\n this._idToPoint.set(textData.id, points[j]);\n this._idToGraphic.set(textData.id, baseMark);\n }\n\n cur++;\n }\n }\n }\n } else {\n for (let i = 0; i < currentBaseMarks.length; i++) {\n const textData = data[i];\n const baseMark = currentBaseMarks[i] as IGraphic;\n if (textData && baseMark) {\n if (!isValid(textData.id)) {\n textData.id = `vrender-component-${this.name}-${i}`;\n }\n this._idToGraphic.set(textData.id, baseMark);\n }\n }\n }\n\n if (this.attribute.animation !== false) {\n const { animation, animationEnter, animationExit, animationUpdate } = this.attribute;\n const animationCfg = isObject(animation) ? animation : {};\n this._animationConfig = {\n enter: animationEnter !== false ? merge({}, DefaultLabelAnimation, animationCfg, animationEnter ?? {}) : false,\n exit: animationExit !== false ? merge({}, DefaultLabelAnimation, animationCfg, animationExit ?? {}) : false,\n update:\n animationUpdate !== false\n ? isArray(animationUpdate)\n ? animationUpdate\n : merge({}, DefaultLabelAnimation, animationCfg, animationUpdate ?? {})\n : false\n };\n } else {\n this._animationConfig = {\n enter: false,\n exit: false,\n update: false\n };\n }\n }\n\n protected getRelatedGraphic(item: LabelItem) {\n return this._idToGraphic.get(item.id);\n }\n\n protected _initText(data: LabelItem[] = []): (IText | IRichText)[] {\n const { textStyle = {} } = this.attribute;\n const labels = [];\n for (let i = 0; i < data.length; i++) {\n const textData = data[i];\n const baseMark = this.getRelatedGraphic(textData);\n if (!baseMark) {\n continue;\n }\n\n const labelAttribute = {\n fill: this._isCollectionBase\n ? isArray(baseMark.attribute.stroke)\n ? baseMark.attribute.stroke.find(entry => !!entry && entry !== true)\n : baseMark.attribute.stroke\n : baseMark.attribute.fill,\n ...textStyle,\n ...textData\n };\n const text = this._createLabelText(labelAttribute);\n labels.push(text);\n }\n\n return labels;\n }\n\n protected _layout(texts: (IText | IRichText)[]): (IText | IRichText)[] {\n const { position, offset } = this.attribute;\n for (let i = 0; i < texts.length; i++) {\n const text = texts[i];\n if (!text) {\n return;\n }\n const textData = text.attribute as LabelItem;\n const baseMark = this.getRelatedGraphic(textData);\n if (!baseMark) {\n continue;\n }\n\n text.attachedThemeGraphic = this as any;\n const textBounds = this.getGraphicBounds(text);\n text.attachedThemeGraphic = null;\n const actualPosition = isFunction(position) ? position(textData) : (position as string);\n\n const graphicBounds = this._isCollectionBase\n ? this.getGraphicBounds(null, this._idToPoint.get(textData.id), actualPosition)\n : this.getGraphicBounds(baseMark, { x: textData.x as number, y: textData.y as number }, actualPosition);\n\n const textLocation = this.labeling(textBounds, graphicBounds, actualPosition, offset);\n\n if (textLocation) {\n text.setAttributes(textLocation);\n }\n }\n\n return texts;\n }\n\n protected _overlapping(labels: (IText | IRichText)[]) {\n if (labels.length === 0) {\n return [];\n }\n const option = (isObject(this.attribute.overlap) ? this.attribute.overlap : {}) as OverlapAttrs;\n const baseMarkGroup = this.getBaseMarkGroup();\n\n const size = option.size ?? {\n width: baseMarkGroup?.AABBBounds.width() ?? 0,\n height: baseMarkGroup?.AABBBounds.height() ?? 0\n };\n\n if (size.width === 0 || size.height === 0) {\n return labels;\n }\n\n const { strategy, priority } = option;\n\n const bmpTool = this._bmpTool || bitmapTool(size.width, size.height);\n const bitmap = this._bitmap || bmpTool.bitmap();\n\n if (priority) {\n labels = labels.sort((a, b) => priority((b.attribute as any).data) - priority((a.attribute as any).data));\n }\n\n if ((strategy as ShiftYStrategy)?.type === 'shiftY') {\n return this._overlapGlobal(labels, option, bmpTool, bitmap);\n }\n return this._overlapByStrategy(labels, option, bmpTool, bitmap);\n }\n\n protected _overlapGlobal(labels: (IText | IRichText)[], option: OverlapAttrs, bmpTool: BitmapTool, bitmap: Bitmap) {\n let result = labels.filter(label => label.attribute.visible && label.attribute.opacity !== 0);\n const { clampForce = true, hideOnHit = true, overlapPadding, strategy } = option;\n if (clampForce) {\n for (let i = 0; i < result.length; i++) {\n const text = labels[i];\n const { dx = 0, dy = 0 } = clampText(text as IText, bmpTool.width, bmpTool.height);\n if (dx !== 0 || dy !== 0) {\n text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });\n }\n }\n }\n result = shiftY(result as any, { maxY: bmpTool.height, ...(strategy as ShiftYStrategy) });\n\n for (let i = 0; i < result.length; i++) {\n const text = result[i];\n const bounds = text.AABBBounds;\n const range = boundToRange(bmpTool, bounds, true);\n if (canPlace(bmpTool, bitmap, bounds, clampForce, overlapPadding)) {\n bitmap.setRange(range);\n } else {\n if (hideOnHit) {\n text.setAttributes({ visible: false });\n } else {\n bitmap.setRange(range);\n }\n }\n }\n\n return result;\n }\n\n protected _overlapByStrategy(\n labels: (IText | IRichText)[],\n option: OverlapAttrs,\n bmpTool: BitmapTool,\n bitmap: Bitmap\n ) {\n const {\n avoidBaseMark,\n strategy = [],\n hideOnHit = true,\n clampForce = true,\n avoidMarks = [],\n overlapPadding\n } = option;\n const result: (IText | IRichText)[] = [];\n\n const checkBounds = (strategy as Strategy[]).some(s => s.type === 'bound');\n // 躲避关联的基础图元\n if (avoidBaseMark) {\n this._baseMarks?.forEach(mark => {\n mark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, mark.AABBBounds, true));\n });\n }\n\n // 躲避指定图元\n if (avoidMarks.length > 0) {\n avoidMarks.forEach(avoid => {\n if (isString(avoid)) {\n getNoneGroupMarksByName(this.getRootNode() as IGroup, avoid).forEach(avoidMark => {\n avoidMark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, avoidMark.AABBBounds, true));\n });\n } else if (avoid.AABBBounds) {\n bitmap.setRange(boundToRange(bmpTool, avoid.AABBBounds, true));\n }\n });\n }\n\n for (let i = 0; i < labels.length; i++) {\n if (labels[i].attribute.visible === false) {\n continue;\n }\n\n const text = labels[i] as IText | IRichText;\n const baseMark = this.getRelatedGraphic(text.attribute);\n text.update();\n if (!isRectIntersect(baseMark.AABBBounds, { x1: 0, x2: bmpTool.width, y1: 0, y2: bmpTool.height }, true)) {\n continue;\n }\n // 默认位置可以放置\n if (canPlace(bmpTool, bitmap, text.AABBBounds, clampForce, overlapPadding)) {\n // 如果配置了限制在图形内部,需要提前判断;\n if (!checkBounds) {\n bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));\n result.push(text);\n continue;\n }\n\n if (\n checkBounds &&\n baseMark &&\n baseMark.AABBBounds &&\n this._canPlaceInside(text.AABBBounds, baseMark.AABBBounds)\n ) {\n bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));\n result.push(text);\n continue;\n }\n }\n\n let hasPlace: ReturnType<typeof place> = false;\n // 发生碰撞,根据策略寻找可放置的位置\n for (let j = 0; j < (strategy as Strategy[]).length; j++) {\n hasPlace = place(\n bmpTool,\n bitmap,\n strategy[j],\n <BaseLabelAttrs>this.attribute,\n text as Text,\n this._isCollectionBase\n ? this.getGraphicBounds(null, this._idToPoint.get((labels[i].attribute as any).id))\n : this.getGraphicBounds(baseMark, labels[i].attribute),\n this.labeling\n );\n if (hasPlace !== false) {\n text.setAttributes({ x: hasPlace.x, y: hasPlace.y });\n result.push(text);\n break;\n }\n }\n\n // 尝试向内挤压\n if (!hasPlace && clampForce) {\n // 向内挤压不考虑 overlapPadding\n const { dx = 0, dy = 0 } = clampText(text as IText, bmpTool.width, bmpTool.height);\n if (dx === 0 && dy === 0) {\n if (canPlace(bmpTool, bitmap, text.AABBBounds)) {\n // xy方向偏移都为0,意味着不考虑 overlapPadding 时,实际上可以放得下\n bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));\n result.push(text);\n continue;\n }\n } else if (\n canPlace(\n bmpTool,\n bitmap,\n {\n x1: text.AABBBounds.x1 + dx,\n x2: text.AABBBounds.x2 + dx,\n y1: text.AABBBounds.y1 + dy,\n y2: text.AABBBounds.y2 + dy\n }\n // 向内 clamp 只处理超出的位移量,不叠加 overlapPadding\n )\n ) {\n text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });\n bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));\n result.push(text);\n continue;\n }\n }\n\n !hasPlace && !hideOnHit && result.push(text);\n }\n return result;\n }\n\n protected getBaseMarkGroup() {\n const { baseMarkGroupName } = this.attribute as BaseLabelAttrs;\n if (!baseMarkGroupName) {\n return;\n }\n return (this.getRootNode() as IGroup).find(node => node.name === baseMarkGroupName, true) as IGroup;\n }\n\n protected getGraphicBounds(graphic?: IGraphic, point?: Partial<PointLocationCfg>, position?: string): IBoundsLike;\n protected getGraphicBounds(graphic?: IGraphic, point: Partial<PointLocationCfg> = {}): IBoundsLike {\n if (graphic) {\n if (graphic.attribute.visible !== false) {\n return graphic.AABBBounds;\n }\n const { x, y } = graphic.attribute;\n return { x1: x, x2: x, y1: y, y2: y } as IBoundsLike;\n }\n const { x, y } = point;\n return { x1: x, x2: x, y1: y, y2: y } as IBoundsLike;\n }\n\n protected _renderLabels(labels: (IText | IRichText)[]) {\n const { syncState } = this.attribute;\n const currentTextMap: Map<any, LabelContent> = new Map();\n const prevTextMap: Map<any, LabelContent> = this._graphicToText || new Map();\n const texts = [] as (IText | IRichText)[];\n const labelLines = [] as ILine[];\n const { visible: showLabelLine } = this.attribute.line ?? {};\n\n labels &&\n labels.forEach((text, index) => {\n const relatedGraphic = this.getRelatedGraphic(text.attribute);\n const textKey = this._isCollectionBase ? (text.attribute as LabelItem).id : relatedGraphic;\n const state = prevTextMap?.get(textKey) ? 'update' : 'enter';\n let labelLine;\n if (showLabelLine) {\n labelLine = this._createLabelLine(text as IText, relatedGraphic);\n }\n if (syncState) {\n this.updateStatesOfLabels([labelLine ? { text, labelLine } : { text }], relatedGraphic.currentStates ?? []);\n }\n\n if (state === 'enter') {\n texts.push(text);\n currentTextMap.set(textKey, labelLine ? { text, labelLine } : { text });\n this._addLabel({ text, labelLine }, texts, labelLines, index);\n } else if (state === 'update') {\n const prevLabel = prevTextMap.get(textKey);\n prevTextMap.delete(textKey);\n currentTextMap.set(textKey, prevLabel);\n this._updateLabel(prevLabel, { text, labelLine });\n }\n });\n\n this._removeLabel(prevTextMap);\n\n this._graphicToText = currentTextMap;\n }\n\n protected _addLabel(\n label: LabelContent,\n texts?: LabelContent['text'][],\n labelLines?: LabelContent['labelLine'][],\n index?: number\n ) {\n const { text, labelLine } = label;\n // TODO: 或许还需要判断关联图元是否有动画?\n const relatedGraphic = this.getRelatedGraphic(text.attribute);\n this._syncStateWithRelatedGraphic(relatedGraphic);\n\n if (this._enableAnimation !== false && this._animationConfig.enter !== false) {\n if (relatedGraphic) {\n const { from, to } = getAnimationAttributes(text.attribute, 'fadeIn');\n if (text) {\n this.add(text);\n }\n\n if (labelLine) {\n labelLines.push(labelLine);\n this.add(labelLine);\n }\n\n // enter的时长如果不是大于0,那么直接跳过动画\n this._animationConfig.enter.duration > 0 &&\n relatedGraphic.once('animate-bind', a => {\n // text和labelLine共用一个from\n text.setAttributes(from);\n labelLine && labelLine.setAttributes(from);\n const listener = this._afterRelatedGraphicAttributeUpdate(\n text,\n texts,\n labelLine,\n labelLines,\n index,\n relatedGraphic,\n to,\n this._animationConfig.enter as ILabelEnterAnimation\n );\n relatedGraphic.on('afterAttributeUpdate', listener);\n });\n }\n } else {\n if (text) {\n this.add(text);\n }\n if (labelLine) {\n this.add(labelLine);\n }\n }\n }\n\n protected _updateLabel(prevLabel: LabelContent, currentLabel: LabelContent) {\n const { text: prevText, labelLine: prevLabelLine } = prevLabel;\n const { text: curText, labelLine: curLabelLine } = currentLabel;\n if (this._enableAnimation !== false && this._animationConfig.update !== false) {\n const { duration, easing } = this._animationConfig.update;\n updateAnimation(prevText, curText, this._animationConfig.update);\n if (prevLabelLine && curLabelLine) {\n prevLabel.labelLine.animate().to(curLabelLine.attribute, duration, easing);\n }\n } else {\n prevLabel.text.setAttributes(curText.attribute as any);\n if (prevLabelLine && curLabelLine) {\n prevLabel.labelLine.setAttributes(curLabelLine.attribute);\n }\n }\n }\n\n protected _removeLabel(textMap: Map<any, LabelContent>) {\n const removeLabelAndLine = (label: LabelContent) => {\n this.removeChild(label.text);\n if (label.labelLine) {\n this.removeChild(label.labelLine);\n }\n };\n\n if (this._enableAnimation !== false && this._animationConfig.exit !== false) {\n const { duration, easing } = this._animationConfig.exit;\n textMap.forEach(label => {\n label.text\n ?.animate()\n .to(getAnimationAttributes(label.text.attribute, 'fadeOut').to, duration, easing)\n .onEnd(() => {\n removeLabelAndLine(label);\n });\n });\n } else {\n textMap.forEach(label => {\n removeLabelAndLine(label);\n });\n }\n }\n\n private updateStatesOfLabels(labels: LabelContent[], currentStates?: string[]) {\n labels.forEach(label => {\n if (label) {\n if (label.text) {\n label.text.useStates(currentStates);\n }\n\n if (label.labelLine) {\n label.labelLine.useStates(currentStates);\n }\n }\n });\n }\n\n protected _handleRelatedGraphicSetState = (e: any) => {\n if (\n e.detail?.type === AttributeUpdateType.STATE ||\n (e.detail?.type === AttributeUpdateType.ANIMATE_UPDATE && e.detail.animationState?.isFirstFrameOfStep)\n ) {\n const currentStates = e.target?.currentStates ?? [];\n const labels = this._isCollectionBase ? [...this._graphicToText.values()] : [this._graphicToText.get(e.target)];\n\n this.updateStatesOfLabels(labels, currentStates);\n }\n };\n\n protected _syncStateWithRelatedGraphic(relatedGraphic: IGraphic) {\n if (this.attribute.syncState && relatedGraphic) {\n relatedGraphic.on('afterAttributeUpdate', this._handleRelatedGraphicSetState);\n }\n }\n\n // 默认labelLine和text共用相同动画属性\n protected _afterRelatedGraphicAttributeUpdate(\n text: IText | IRichText,\n texts: (IText | IRichText)[],\n labelLine: ILine,\n labelLines: ILine[],\n index: number,\n relatedGraphic: IGraphic,\n to: any,\n { mode, duration, easing, delay }: ILabelAnimation\n ) {\n // TODO: 跟随动画\n const listener = (event: any) => {\n const { detail } = event;\n if (!detail) {\n return {};\n }\n const step = detail.animationState?.step;\n const isValidAnimateState =\n detail.type === AttributeUpdateType.ANIMATE_UPDATE &&\n step &&\n // 不是第一个wait\n !(step.type === 'wait' && step.prev?.type == null);\n\n if (!isValidAnimateState) {\n return {};\n }\n // const prevStep = step.prev;\n // if (prevStep && prevStep.type === 'wait' && prevStep.prev?.type == null) {\n // delay = delay ?? step.position;\n // }\n if (detail.type === AttributeUpdateType.ANIMATE_END) {\n text.setAttributes(to);\n labelLine && labelLine.setAttributes(to);\n return;\n }\n\n const onStart = () => {\n if (relatedGraphic) {\n relatedGraphic.onAnimateBind = undefined;\n relatedGraphic.removeEventListener('afterAttributeUpdate', listener);\n }\n };\n\n switch (mode) {\n case 'after':\n // 3. 当前关联图元的动画播放结束后\n if (detail.animationState.end) {\n text.animate({ onStart }).wait(delay).to(to, duration, easing);\n labelLine && labelLine.animate().wait(delay).to(to, duration, easing);\n }\n break;\n case 'after-all':\n // 2. 所有完成后才开始;\n if (index === texts.length - 1) {\n if (detail.animationState.end) {\n texts.forEach(t => {\n t.animate({ onStart }).wait(delay).to(to, duration, easing);\n });\n labelLines.forEach(t => {\n t.animate().wait(delay).to(to, duration, easing);\n });\n }\n }\n break;\n case 'same-time':\n default:\n if (this._isCollectionBase) {\n const point = this._idToPoint.get((text.attribute as LabelItem).id);\n if (\n point &&\n (!text.animates || !text.animates.has('label-animate')) &&\n relatedGraphic.containsPoint(point.x, point.y, IContainPointMode.LOCAL, this.stage?.getPickerService())\n ) {\n text.animate({ onStart }).wait(delay).to(to, duration, easing);\n labelLine && labelLine.animate().wait(delay).to(to, duration, easing);\n }\n } else if (detail.animationState.isFirstFrameOfStep) {\n text.animate({ onStart }).wait(delay).to(to, duration, easing);\n labelLine && labelLine.animate().wait(delay).to(to, duration, easing);\n }\n\n break;\n }\n };\n return listener;\n }\n\n protected _smartInvert(labels: (IText | IRichText)[]) {\n const option = (isObject(this.attribute.smartInvert) ? this.attribute.smartInvert : {}) as SmartInvertAttrs;\n const { textType, contrastRatiosThreshold, alternativeColors, mode, interactInvertType } = option;\n const fillStrategy = option.fillStrategy ?? 'invertBase';\n const strokeStrategy = option.strokeStrategy ?? 'base';\n const brightColor = option.brightColor ?? '#ffffff';\n const darkColor = option.darkColor ?? '#000000';\n const outsideEnable = option.outsideEnable ?? false;\n\n if (fillStrategy === 'null' && strokeStrategy === 'null') {\n return;\n }\n\n for (let i = 0; i < labels.length; i++) {\n const label = labels[i];\n if (!label) {\n continue;\n }\n\n const baseMark = this.getRelatedGraphic(label.attribute as LabelItem);\n\n /**\n * 增加smartInvert时fillStrategy和 strokeStrategy的四种策略:\n * base(baseMark色),\n * inverBase(执行智能反色),\n * similarBase(智能反色的补色),\n * null(不执行智能反色,保持fill设置的颜色)\n * */\n const backgroundColor = baseMark.attribute.fill as IColor;\n const foregroundColor = label.attribute.fill as IColor;\n const invertColor = labelSmartInvert(\n foregroundColor,\n backgroundColor,\n textType,\n contrastRatiosThreshold,\n alternativeColors,\n mode\n );\n const similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;\n const isInside = this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds);\n const isIntersect =\n !isInside && label.AABBBounds && baseMark.AABBBounds && baseMark.AABBBounds.intersects(label.AABBBounds);\n\n if (isInside || outsideEnable || (isIntersect && interactInvertType === 'inside')) {\n // 按照标签展示在柱子内部的情况,执行反色逻辑\n const fill = smartInvertStrategy(fillStrategy, backgroundColor, invertColor, similarColor);\n fill && label.setAttributes({ fill });\n\n if (label.attribute.lineWidth === 0 || label.attribute.strokeOpacity === 0) {\n continue;\n }\n\n const stroke = smartInvertStrategy(strokeStrategy, backgroundColor, invertColor, similarColor);\n stroke && label.setAttributes({ stroke });\n } else if (isIntersect && interactInvertType !== 'none') {\n // 存在相交的情况\n /** 当label无法设置stroke时,不进行反色计算(容易反色为白色与白色背景混合不可见) */\n if (label.attribute.lineWidth === 0 || label.attribute.strokeOpacity === 0) {\n continue;\n }\n /** 当label设置stroke时,保留stroke设置的颜色,根据stroke对fill做反色 */\n if (label.attribute.stroke) {\n // stroke 作为背景色进行反色计算\n label.setAttributes({\n fill: labelSmartInvert(\n label.attribute.fill as IColor,\n label.attribute.stroke as IColor,\n textType,\n contrastRatiosThreshold,\n alternativeColors,\n mode\n )\n });\n continue;\n }\n /** 当label未设置stroke,且可设置stroke时,正常计算 */\n const fill = smartInvertStrategy(fillStrategy, backgroundColor, invertColor, similarColor);\n fill && label.setAttributes({ fill });\n\n const stroke = smartInvertStrategy(strokeStrategy, backgroundColor, invertColor, similarColor);\n stroke && label.setAttributes({ stroke });\n }\n }\n }\n\n /**\n * 是否在图形内部\n * @param textBound\n * @param shapeBound\n * @returns\n */\n protected _canPlaceInside(textBound: IBoundsLike, shapeBound: IAABBBounds) {\n if (!textBound || !shapeBound) {\n return false;\n }\n return shapeBound.encloses(textBound);\n }\n\n setLocation(point: PointLocationCfg) {\n this.translateTo(point.x, point.y);\n }\n\n disableAnimation() {\n this._enableAnimation = false;\n }\n\n enableAnimation() {\n this._enableAnimation = true;\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { isFunction, isValid } from "@visactor/vutils";
2
2
 
3
- import { boundToRange } from "./scaler";
3
+ import { boundToRange, clampRangeByBitmap } from "./scaler";
4
4
 
5
5
  export function canPlace($, bitmap, bound, checkBound = !0, pad = 0) {
6
6
  let range = bound;
@@ -10,7 +10,9 @@ export function canPlace($, bitmap, bound, checkBound = !0, pad = 0) {
10
10
  y1: bound.y1 - pad,
11
11
  y2: bound.y2 + pad
12
12
  }), range = boundToRange($, range);
13
- return !(checkBound && bitmap.outOfBounds(range)) && !bitmap.getRange(range);
13
+ const outOfBounds = bitmap.outOfBounds(range);
14
+ return (!checkBound || !outOfBounds) && (outOfBounds && (range = clampRangeByBitmap($, range)),
15
+ !bitmap.getRange(range));
14
16
  }
15
17
 
16
18
  export function canPlaceInside(textBound, shapeBound) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/label/overlap/place.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAMvD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAiCxC,MAAM,UAAU,QAAQ,CAAC,CAAa,EAAE,MAAc,EAAE,KAAkB,EAAE,UAAU,GAAG,IAAI,EAAE,GAAG,GAAG,CAAC;IACpG,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,IAAI,GAAG,GAAG,CAAC,EAAE;QACX,KAAK,GAAG;YACN,EAAE,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG;YAClB,EAAE,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG;YAClB,EAAE,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG;YAClB,EAAE,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG;SACnB,CAAC;KACH;IACD,KAAK,GAAG,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAE/B,MAAM,WAAW,GAAG,UAAU,IAAI,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAE5D,IAAI,WAAW,EAAE;QACf,O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ED,MAAM,UAAU,SAAS,CAAC,IAAW,EAAE,KAAa,EAAE,MAAc;IAClE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC;IAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAE9B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAE9B,IAAI,EAAE,GAAG,CAAC,CAAC;IACX,IAAI,EAAE,GAAG,CAAC,CAAC;IAGX,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK,EAAE;QACpC,EAAE,GAAG,CAAC,IAAI,CAAC;KACZ;SAAM,IAAI,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE;QACrD,EAAE,GAAG,KAAK,GAAG,IAAI,CAAC;KACnB;IAGD,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,IAAI,IAAI,MAAM,EAAE;QACrC,EAAE,GAAG,CAAC,IAAI,CAAC;KACZ;SAAM,IAAI,IAAI,GAAG,MAAM,IAAI,IAAI,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE;QACvD,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC;KACpB;IAED,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;AACpB,CAAC","file":"place.js","sourcesContent":["import type { IText, Text } from '@visactor/vrender-core';\nimport type { IAABBBounds, IBoundsLike } from '@visactor/vutils';\nimport { isFunction, isValid } from '@visactor/vutils';\nimport type { PointLocationCfg } from '../../core/type';\nimport type { LabelBase } from '../base';\nimport type { BaseLabelAttrs, OverlapAttrs, Strategy } from '../type';\nimport type { Bitmap } from './bitmap';\nimport type { BitmapTool } from './scaler';\nimport { boundToRange } from './scaler';\n\n/**\n * 防重叠逻辑参考 https://github.com/vega/vega/\n * Copyright (c) 2015-2023, University of Washington Interactive Data Lab\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n 2. Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n 3. Neither the name of the copyright holder nor the names of its contributors\n may be used to endorse or promote products derived from this software\n without specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\n FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nexport function canPlace($: BitmapTool, bitmap: Bitmap, bound: IBoundsLike, checkBound = true, pad = 0) {\n let range = bound;\n if (pad > 0) {\n range = {\n x1: bound.x1 - pad,\n x2: bound.x2 + pad,\n y1: bound.y1 - pad,\n y2: bound.y2 + pad\n };\n }\n range = boundToRange($, range);\n\n const outOfBounds = checkBound && bitmap.outOfBounds(range);\n\n if (outOfBounds) {\n return false;\n }\n\n return !bitmap.getRange(range);\n}\n\n/**\n * 是否在图形内部\n * @param textBound\n * @param shapeBound\n * @returns\n */\nexport function canPlaceInside(textBound: IBoundsLike, shapeBound: IAABBBounds) {\n if (!textBound || !shapeBound) {\n return false;\n }\n return shapeBound.encloses(textBound);\n}\n\nexport function placeToCandidates(\n $: BitmapTool,\n bitmap: Bitmap,\n text: Text,\n candidates: PointLocationCfg[] = [],\n clampForce = true,\n pad = 0\n): PointLocationCfg | false {\n const validCandidates = candidates.filter(candidate => isValid(candidate));\n for (let i = 0; i < validCandidates.length; i++) {\n const tempText = text.clone();\n tempText.setAttributes(validCandidates[i]);\n tempText.update();\n\n if (canPlace($, bitmap, tempText.AABBBounds, clampForce, pad)) {\n bitmap.setRange(boundToRange($, tempText.AABBBounds, true));\n return validCandidates[i];\n }\n }\n return false;\n}\n\nexport function place<T extends BaseLabelAttrs>(\n $: BitmapTool,\n bitmap: Bitmap,\n s: Strategy,\n attrs: T,\n text: Text,\n bounds: IBoundsLike,\n labeling?: LabelBase<T>['labeling']\n): PointLocationCfg | false {\n const clampForce = (attrs.overlap as OverlapAttrs)?.clampForce;\n const overlapPadding = (attrs.overlap as OverlapAttrs)?.overlapPadding;\n if (s.type === 'bound' || s.type === 'position') {\n if (isFunction(labeling)) {\n // TODO:这里可以 filter 掉初始位置,提升一部分性能\n const userPosition = isFunction(s.position) ? s.position(text.attribute) : s.position;\n const positions = (userPosition || defaultLabelPosition(attrs.type)) as string[];\n const candidates = positions.map(p => labeling(text.AABBBounds, bounds, p, attrs.offset) as PointLocationCfg);\n return placeToCandidates($, bitmap, text, candidates, clampForce, overlapPadding);\n }\n return false;\n }\n\n if (s.type === 'moveY') {\n const offset = s.offset ? (isFunction(s.offset) ? s.offset(text.attribute) : s.offset) : [];\n const candidates = offset.map(dy => {\n return { x: text.attribute.x as number, y: (text.attribute.y as number) + dy };\n });\n return placeToCandidates($, bitmap, text, candidates, clampForce, overlapPadding);\n }\n\n if (s.type === 'moveX') {\n const offset = s.offset ? (isFunction(s.offset) ? s.offset(text.attribute) : s.offset) : [];\n const candidates = offset.map(dx => {\n return { x: (text.attribute.x as number) + dx, y: text.attribute.y as number };\n });\n return placeToCandidates($, bitmap, text, candidates, clampForce, overlapPadding);\n }\n return false;\n}\n\nexport const DefaultPositions = [\n 'top',\n 'bottom',\n 'right',\n 'left',\n 'top-right',\n 'bottom-right',\n 'top-left',\n 'bottom-left'\n];\nexport const DefaultRectPositions = ['top', 'inside-top', 'inside'];\n\nexport function defaultLabelPosition(type?: string) {\n switch (type) {\n case 'rect':\n return DefaultRectPositions;\n default:\n return DefaultPositions;\n }\n}\n\nexport function clampText(text: IText, width: number, height: number) {\n const { x1, x2, y1, y2 } = text.AABBBounds;\n const minX = Math.min(x1, x2);\n const maxX = Math.max(x1, x2);\n\n const minY = Math.min(y1, y2);\n const maxY = Math.max(y1, y2);\n\n let dx = 0;\n let dy = 0;\n\n // x 方向\n if (minX < 0 && maxX - minX <= width) {\n dx = -minX;\n } else if (maxX > width && minX - (maxX - width) >= 0) {\n dx = width - maxX;\n }\n\n // y 方向\n if (minY < 0 && maxY - minY <= height) {\n dy = -minY;\n } else if (maxY > height && minY - (maxY - height) >= 0) {\n dy = height - maxY;\n }\n\n return { dx, dy };\n}\n"]}
1
+ {"version":3,"sources":["../src/label/overlap/place.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAMvD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAiC5D,MAAM,UAAU,QAAQ,CAAC,CAAa,EAAE,MAAc,EAAE,KAAkB,EAAE,UAAU,GAAG,IAAI,EA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;KACZ;SAAM,IAAI,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE;QACrD,EAAE,GAAG,KAAK,GAAG,IAAI,CAAC;KACnB;IAGD,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,IAAI,IAAI,MAAM,EAAE;QACrC,EAAE,GAAG,CAAC,IAAI,CAAC;KACZ;SAAM,IAAI,IAAI,GAAG,MAAM,IAAI,IAAI,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE;QACvD,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC;KACpB;IAED,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;AACpB,CAAC","file":"place.js","sourcesContent":["import type { IText, Text } from '@visactor/vrender-core';\nimport type { IAABBBounds, IBoundsLike } from '@visactor/vutils';\nimport { isFunction, isValid } from '@visactor/vutils';\nimport type { PointLocationCfg } from '../../core/type';\nimport type { LabelBase } from '../base';\nimport type { BaseLabelAttrs, OverlapAttrs, Strategy } from '../type';\nimport type { Bitmap } from './bitmap';\nimport type { BitmapTool } from './scaler';\nimport { boundToRange, clampRangeByBitmap } from './scaler';\n\n/**\n * 防重叠逻辑参考 https://github.com/vega/vega/\n * Copyright (c) 2015-2023, University of Washington Interactive Data Lab\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n 2. Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n 3. Neither the name of the copyright holder nor the names of its contributors\n may be used to endorse or promote products derived from this software\n without specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\n FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nexport function canPlace($: BitmapTool, bitmap: Bitmap, bound: IBoundsLike, checkBound = true, pad = 0) {\n let range = bound;\n if (pad > 0) {\n range = {\n x1: bound.x1 - pad,\n x2: bound.x2 + pad,\n y1: bound.y1 - pad,\n y2: bound.y2 + pad\n };\n }\n range = boundToRange($, range);\n\n const outOfBounds = bitmap.outOfBounds(range);\n\n if (checkBound && outOfBounds) {\n return false;\n }\n\n // 超出边界,需要将判断区域调整到可视区域内\n if (outOfBounds) {\n range = clampRangeByBitmap($, range);\n }\n\n return !bitmap.getRange(range);\n}\n\n/**\n * 是否在图形内部\n * @param textBound\n * @param shapeBound\n * @returns\n */\nexport function canPlaceInside(textBound: IBoundsLike, shapeBound: IAABBBounds) {\n if (!textBound || !shapeBound) {\n return false;\n }\n return shapeBound.encloses(textBound);\n}\n\nexport function placeToCandidates(\n $: BitmapTool,\n bitmap: Bitmap,\n text: Text,\n candidates: PointLocationCfg[] = [],\n clampForce = true,\n pad = 0\n): PointLocationCfg | false {\n const validCandidates = candidates.filter(candidate => isValid(candidate));\n for (let i = 0; i < validCandidates.length; i++) {\n const tempText = text.clone();\n tempText.setAttributes(validCandidates[i]);\n tempText.update();\n\n if (canPlace($, bitmap, tempText.AABBBounds, clampForce, pad)) {\n bitmap.setRange(boundToRange($, tempText.AABBBounds, true));\n return validCandidates[i];\n }\n }\n return false;\n}\n\nexport function place<T extends BaseLabelAttrs>(\n $: BitmapTool,\n bitmap: Bitmap,\n s: Strategy,\n attrs: T,\n text: Text,\n bounds: IBoundsLike,\n labeling?: LabelBase<T>['labeling']\n): PointLocationCfg | false {\n const clampForce = (attrs.overlap as OverlapAttrs)?.clampForce;\n const overlapPadding = (attrs.overlap as OverlapAttrs)?.overlapPadding;\n if (s.type === 'bound' || s.type === 'position') {\n if (isFunction(labeling)) {\n // TODO:这里可以 filter 掉初始位置,提升一部分性能\n const userPosition = isFunction(s.position) ? s.position(text.attribute) : s.position;\n const positions = (userPosition || defaultLabelPosition(attrs.type)) as string[];\n const candidates = positions.map(p => labeling(text.AABBBounds, bounds, p, attrs.offset) as PointLocationCfg);\n return placeToCandidates($, bitmap, text, candidates, clampForce, overlapPadding);\n }\n return false;\n }\n\n if (s.type === 'moveY') {\n const offset = s.offset ? (isFunction(s.offset) ? s.offset(text.attribute) : s.offset) : [];\n const candidates = offset.map(dy => {\n return { x: text.attribute.x as number, y: (text.attribute.y as number) + dy };\n });\n return placeToCandidates($, bitmap, text, candidates, clampForce, overlapPadding);\n }\n\n if (s.type === 'moveX') {\n const offset = s.offset ? (isFunction(s.offset) ? s.offset(text.attribute) : s.offset) : [];\n const candidates = offset.map(dx => {\n return { x: (text.attribute.x as number) + dx, y: text.attribute.y as number };\n });\n return placeToCandidates($, bitmap, text, candidates, clampForce, overlapPadding);\n }\n return false;\n}\n\nexport const DefaultPositions = [\n 'top',\n 'bottom',\n 'right',\n 'left',\n 'top-right',\n 'bottom-right',\n 'top-left',\n 'bottom-left'\n];\nexport const DefaultRectPositions = ['top', 'inside-top', 'inside'];\n\nexport function defaultLabelPosition(type?: string) {\n switch (type) {\n case 'rect':\n return DefaultRectPositions;\n default:\n return DefaultPositions;\n }\n}\n\nexport function clampText(text: IText, width: number, height: number) {\n const { x1, x2, y1, y2 } = text.AABBBounds;\n const minX = Math.min(x1, x2);\n const maxX = Math.max(x1, x2);\n\n const minY = Math.min(y1, y2);\n const maxY = Math.max(y1, y2);\n\n let dx = 0;\n let dy = 0;\n\n // x 方向\n if (minX < 0 && maxX - minX <= width) {\n dx = -minX;\n } else if (maxX > width && minX - (maxX - width) >= 0) {\n dx = width - maxX;\n }\n\n // y 方向\n if (minY < 0 && maxY - minY <= height) {\n dy = -minY;\n } else if (maxY > height && minY - (maxY - height) >= 0) {\n dy = height - maxY;\n }\n\n return { dx, dy };\n}\n"]}
@@ -29,6 +29,12 @@ export declare function bitmapTool(width: number, height: number, padding?: {
29
29
  width: number;
30
30
  height: number;
31
31
  };
32
+ export declare function clampRangeByBitmap($: BitmapTool, range: IBoundsLike): {
33
+ x1: number;
34
+ x2: number;
35
+ y1: number;
36
+ y2: number;
37
+ };
32
38
  export declare function boundToRange($: BitmapTool, bound: IBoundsLike, clamp?: boolean): {
33
39
  x1: number;
34
40
  x2: number;
@@ -14,17 +14,18 @@ export function bitmapTool(width, height, padding = {
14
14
  scale.width = width, scale.height = height, scale;
15
15
  }
16
16
 
17
- export function boundToRange($, bound, clamp = !1) {
18
- if (clamp) {
19
- const {x1: x1, x2: x2, y1: y1, y2: y2} = bound, _x1 = clampRange(x1, 0, $.width), _x2 = clampRange(x2, 0, $.width), _y1 = clampRange(y1, 0, $.height), _y2 = clampRange(y2, 0, $.height);
20
- return {
21
- x1: $.x(_x1),
22
- x2: $.x(_x2),
23
- y1: $.y(_y1),
24
- y2: $.y(_y2)
25
- };
26
- }
17
+ export function clampRangeByBitmap($, range) {
18
+ const {x1: x1, x2: x2, y1: y1, y2: y2} = range, _x1 = clampRange(x1, 0, $.width), _x2 = clampRange(x2, 0, $.width), _y1 = clampRange(y1, 0, $.height), _y2 = clampRange(y2, 0, $.height);
27
19
  return {
20
+ x1: $.x(_x1),
21
+ x2: $.x(_x2),
22
+ y1: $.y(_y1),
23
+ y2: $.y(_y2)
24
+ };
25
+ }
26
+
27
+ export function boundToRange($, bound, clamp = !1) {
28
+ return clamp ? clampRangeByBitmap($, bound) : {
28
29
  x1: $.x(bound.x1),
29
30
  x2: $.x(bound.x2),
30
31
  y1: $.y(bound.y1),