@visactor/vrender-components 1.1.0-alpha.22 → 1.1.0-alpha.23

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.
package/dist/index.es.js CHANGED
@@ -24437,17 +24437,6 @@ function shiftY(texts, option) {
24437
24437
  }
24438
24438
 
24439
24439
  loadLabelComponent();
24440
- function cloneAttributeSnapshot(value) {
24441
- if (!isObject(value) || isArray(value)) {
24442
- return value;
24443
- }
24444
- const snapshot = {};
24445
- Object.keys(value).forEach(key => {
24446
- const nextValue = value[key];
24447
- snapshot[key] = isObject(nextValue) && !isArray(nextValue) ? cloneAttributeSnapshot(nextValue) : nextValue;
24448
- });
24449
- return snapshot;
24450
- }
24451
24440
  class LabelBase extends AnimateComponent {
24452
24441
  setBitmap(bitmap) {
24453
24442
  this._bitmap = bitmap;
@@ -24518,7 +24507,7 @@ class LabelBase extends AnimateComponent {
24518
24507
  return;
24519
24508
  }
24520
24509
  _getLabelLinePoints(text, baseMark) {
24521
- return connectLineBetweenBounds(text.AABBBounds, baseMark === null || baseMark === void 0 ? void 0 : baseMark.AABBBounds);
24510
+ return connectLineBetweenBounds(text.AABBBounds, this.getGraphicFinalLayoutBounds(baseMark));
24522
24511
  }
24523
24512
  _createLabelLine(text, baseMark) {
24524
24513
  const points = this._getLabelLinePoints(text, baseMark);
@@ -24633,17 +24622,12 @@ class LabelBase extends AnimateComponent {
24633
24622
  if (this._exitReleaseState) {
24634
24623
  return;
24635
24624
  }
24625
+ this._finalLayoutBoundsCache = undefined;
24636
24626
  this._prepare();
24637
24627
  if (isNil(this._idToGraphic) || (this._isCollectionBase && isNil(this._idToPoint))) {
24638
24628
  return;
24639
24629
  }
24640
- const markAttributeList = [];
24641
- if (this._enableAnimation !== false) {
24642
- this._baseMarks.forEach(mark => {
24643
- markAttributeList.push(cloneAttributeSnapshot(mark.attribute));
24644
- mark.initAttributes(this.getGraphicFinalLayoutAttributes(mark));
24645
- });
24646
- }
24630
+ this._finalLayoutBoundsCache = new Map();
24647
24631
  const { overlap, smartInvert, dataFilter, customLayoutFunc, customOverlapFunc } = this.attribute;
24648
24632
  let data = this.attribute.data;
24649
24633
  if (isFunction(dataFilter)) {
@@ -24694,11 +24678,7 @@ class LabelBase extends AnimateComponent {
24694
24678
  this._smartInvert(labels);
24695
24679
  }
24696
24680
  this._renderLabels(labels);
24697
- if (this._enableAnimation !== false) {
24698
- this._baseMarks.forEach((mark, index) => {
24699
- mark.initAttributes(markAttributeList[index]);
24700
- });
24701
- }
24681
+ this._finalLayoutBoundsCache = undefined;
24702
24682
  }
24703
24683
  _bindEvent(target) {
24704
24684
  if (this.attribute.disableTriggerEvent) {
@@ -24818,6 +24798,33 @@ class LabelBase extends AnimateComponent {
24818
24798
  var _a;
24819
24799
  return !!((_a = graphic === null || graphic === void 0 ? void 0 : graphic.context) === null || _a === void 0 ? void 0 : _a.finalAttrs);
24820
24800
  }
24801
+ shouldUseGraphicFinalLayoutAttributes(graphic) {
24802
+ var _a;
24803
+ return !!graphic && (!!((_a = graphic.context) === null || _a === void 0 ? void 0 : _a.animationState) || this.hasGraphicContextFinalLayoutAttributes(graphic));
24804
+ }
24805
+ getGraphicFinalLayoutBounds(graphic) {
24806
+ var _a, _b;
24807
+ if (!graphic) {
24808
+ return;
24809
+ }
24810
+ const useFinalAttrs = this.shouldUseGraphicFinalLayoutAttributes(graphic);
24811
+ const graphicAttrs = useFinalAttrs ? this.getGraphicFinalLayoutAttributes(graphic) : graphic.attribute;
24812
+ if ((graphicAttrs === null || graphicAttrs === void 0 ? void 0 : graphicAttrs.visible) === false) {
24813
+ return;
24814
+ }
24815
+ if (!useFinalAttrs) {
24816
+ return graphic.AABBBounds;
24817
+ }
24818
+ const cachedBounds = (_a = this._finalLayoutBoundsCache) === null || _a === void 0 ? void 0 : _a.get(graphic);
24819
+ if (cachedBounds) {
24820
+ return cachedBounds;
24821
+ }
24822
+ const clonedGraphic = graphic.clone();
24823
+ clonedGraphic.initAttributes(Object.assign(Object.assign({}, clonedGraphic.attribute), graphicAttrs));
24824
+ const bounds = clonedGraphic.AABBBounds;
24825
+ (_b = this._finalLayoutBoundsCache) === null || _b === void 0 ? void 0 : _b.set(graphic, bounds);
24826
+ return bounds;
24827
+ }
24821
24828
  _initText(data = []) {
24822
24829
  const { textStyle = {} } = this.attribute;
24823
24830
  const labels = [];
@@ -24981,7 +24988,8 @@ class LabelBase extends AnimateComponent {
24981
24988
  const checkBounds = strategy.some(s => s.type === 'bound');
24982
24989
  if (avoidBaseMark) {
24983
24990
  (_a = this._baseMarks) === null || _a === void 0 ? void 0 : _a.forEach(mark => {
24984
- mark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, mark.AABBBounds, true));
24991
+ const markBounds = this.getGraphicFinalLayoutBounds(mark);
24992
+ markBounds && bitmap.setRange(boundToRange(bmpTool, markBounds, true));
24985
24993
  });
24986
24994
  }
24987
24995
  if (avoidMarks.length > 0) {
@@ -25014,8 +25022,7 @@ class LabelBase extends AnimateComponent {
25014
25022
  }
25015
25023
  if (checkBounds &&
25016
25024
  baseMark &&
25017
- baseMark.AABBBounds &&
25018
- this._canPlaceInside(text.AABBBounds, baseMark.AABBBounds)) {
25025
+ this._canPlaceInside(text.AABBBounds, this.getGraphicFinalLayoutBounds(baseMark))) {
25019
25026
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
25020
25027
  result.push(text);
25021
25028
  continue;
@@ -25052,13 +25059,18 @@ class LabelBase extends AnimateComponent {
25052
25059
  return result;
25053
25060
  }
25054
25061
  isMarkInsideRect(baseMark, bmpTool) {
25062
+ if (!baseMark) {
25063
+ return false;
25064
+ }
25055
25065
  const { left, right, top, bottom } = bmpTool.padding;
25056
25066
  const rect = { x1: -left, x2: bmpTool.width + right, y1: -top, y2: bmpTool.height + bottom };
25057
- const bounds = baseMark.AABBBounds;
25058
- if (bounds.width() !== 0 && bounds.height() !== 0) {
25059
- return isRectIntersect(baseMark.AABBBounds, rect, true);
25067
+ const bounds = this.getGraphicFinalLayoutBounds(baseMark);
25068
+ if (bounds && bounds.width() !== 0 && bounds.height() !== 0) {
25069
+ return isRectIntersect(bounds, rect, true);
25060
25070
  }
25061
- const { attribute } = baseMark;
25071
+ const attribute = this.shouldUseGraphicFinalLayoutAttributes(baseMark)
25072
+ ? this.getGraphicFinalLayoutAttributes(baseMark)
25073
+ : baseMark.attribute;
25062
25074
  if (baseMark.type === 'rect') {
25063
25075
  const { x, x1, y, y1 } = attribute;
25064
25076
  return pointInRect({ x: x !== null && x !== void 0 ? x : x1, y: y !== null && y !== void 0 ? y : y1 }, rect, true);
@@ -25076,17 +25088,14 @@ class LabelBase extends AnimateComponent {
25076
25088
  return this.getRootNode().find(node => node.name === baseMarkGroupName, true);
25077
25089
  }
25078
25090
  getGraphicBounds(graphic, point = {}, position) {
25079
- var _a;
25080
25091
  if (graphic) {
25081
- if (graphic.attribute.visible !== false) {
25082
- if (((_a = graphic.context) === null || _a === void 0 ? void 0 : _a.animationState) || this.hasGraphicContextFinalLayoutAttributes(graphic)) {
25083
- const clonedGraphic = graphic.clone();
25084
- Object.assign(clonedGraphic.attribute, this.getGraphicFinalLayoutAttributes(graphic));
25085
- return clonedGraphic.AABBBounds;
25086
- }
25087
- return graphic.AABBBounds;
25092
+ const graphicAttrs = this.shouldUseGraphicFinalLayoutAttributes(graphic)
25093
+ ? this.getGraphicFinalLayoutAttributes(graphic)
25094
+ : graphic.attribute;
25095
+ if (graphicAttrs.visible !== false) {
25096
+ return this.getGraphicFinalLayoutBounds(graphic);
25088
25097
  }
25089
- const { x, y } = graphic.attribute;
25098
+ const { x, y } = graphicAttrs;
25090
25099
  return { x1: x, x2: x, y1: y, y2: y };
25091
25100
  }
25092
25101
  if (point && position && position === 'inside-middle') {
@@ -25283,8 +25292,9 @@ class LabelBase extends AnimateComponent {
25283
25292
  }
25284
25293
  const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode);
25285
25294
  const similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;
25286
- const isInside = this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds);
25287
- const isIntersect = !isInside && label.AABBBounds && baseMark.AABBBounds && baseMark.AABBBounds.intersects(label.AABBBounds);
25295
+ const baseMarkBounds = this.getGraphicFinalLayoutBounds(baseMark);
25296
+ const isInside = this._canPlaceInside(label.AABBBounds, baseMarkBounds);
25297
+ const isIntersect = !isInside && label.AABBBounds && baseMarkBounds && baseMarkBounds.intersects(label.AABBBounds);
25288
25298
  if (isInside || outsideEnable || (isIntersect && interactInvertType === 'inside')) {
25289
25299
  const fill = smartInvertStrategy(fillStrategy, backgroundColor, invertColor, similarColor);
25290
25300
  fill && label.setAttributes({ fill });
@@ -36906,6 +36916,6 @@ TableSeriesNumber.defaultAttributes = {
36906
36916
  select: true
36907
36917
  };
36908
36918
 
36909
- const version = "1.1.0-alpha.22";
36919
+ const version = "1.1.0-alpha.23";
36910
36920
 
36911
36921
  export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IDataZoomEvent, IDataZoomInteractiveEvent, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PolygonSectorCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SeriesNumberCellStateValue, SeriesNumberEvent, SizeContinuousLegend, Slider, StoryLabelItem, Switch, SymbolLabel, TableSeriesNumber, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, WeatherBox, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, installPoptipToApp, installScrollbarToApp, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, loadScrollbar, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };
@@ -37,4 +37,5 @@ PolygonSectorCrosshair.defaultAttributes = {
37
37
  fill: "#b2bacf",
38
38
  opacity: .2
39
39
  }
40
- };
40
+ };
41
+ //# sourceMappingURL=polygon-sector.js.map
@@ -33,5 +33,4 @@ RectCrosshair.defaultAttributes = {
33
33
  fill: "#b2bacf",
34
34
  opacity: .2
35
35
  }
36
- };
37
- //# sourceMappingURL=rect.js.map
36
+ };
package/es/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "1.1.0-alpha.22";
1
+ export declare const version = "1.1.0-alpha.23";
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 = "1.1.0-alpha.22";
1
+ export const version = "1.1.0-alpha.23";
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,gBAAgB,CAAC;AAExC,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,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"1.1.0-alpha.22\";\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 './weather';\nexport * from './util';\nexport * from './switch';\nexport * from './label-item';\nexport * from './table-series-number';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAExC,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,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"1.1.0-alpha.23\";\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 './weather';\nexport * from './util';\nexport * from './switch';\nexport * from './label-item';\nexport * from './table-series-number';\n"]}
@@ -27,6 +27,7 @@ export declare class LabelBase<T extends BaseLabelAttrs> extends AnimateComponen
27
27
  private _lastSelect;
28
28
  private _enableAnimation;
29
29
  private _exitReleaseState?;
30
+ private _finalLayoutBoundsCache?;
30
31
  constructor(attributes: BaseLabelAttrs, options?: ComponentOptions);
31
32
  protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: BaseLabelAttrs['position'], offset?: number): {
32
33
  x: number;
@@ -52,6 +53,8 @@ export declare class LabelBase<T extends BaseLabelAttrs> extends AnimateComponen
52
53
  protected getRelatedGraphic(item: LabelItem): IGraphic<Partial<import("@visactor/vrender-core").IGraphicAttribute>>;
53
54
  protected getGraphicFinalLayoutAttributes<TAttrs extends Record<string, any> = Record<string, any>>(graphic: IGraphic): TAttrs;
54
55
  protected hasGraphicContextFinalLayoutAttributes(graphic?: IGraphic): boolean;
56
+ protected shouldUseGraphicFinalLayoutAttributes(graphic?: IGraphic): boolean;
57
+ protected getGraphicFinalLayoutBounds(graphic?: IGraphic): IAABBBounds | undefined;
55
58
  protected _initText(data?: LabelItem[]): (IText | IRichText)[];
56
59
  protected _layout(texts: (IText | IRichText)[]): (IText | IRichText)[];
57
60
  protected _overlapping(labels: (IText | IRichText)[]): (IRichText | IText)[];
@@ -72,7 +75,7 @@ export declare class LabelBase<T extends BaseLabelAttrs> extends AnimateComponen
72
75
  private updateStatesOfLabels;
73
76
  protected _handleRelatedGraphicSetState: (e: any) => void;
74
77
  protected _smartInvert(labels: (IText | IRichText)[]): void;
75
- protected _canPlaceInside(textBound: IBoundsLike, shapeBound: IAABBBounds): boolean;
78
+ protected _canPlaceInside(textBound: IBoundsLike, shapeBound?: IAABBBounds): boolean;
76
79
  release(all?: boolean): void;
77
80
  setLocation(point: PointLocationCfg): void;
78
81
  disableAnimation(): void;
package/es/label/base.js CHANGED
@@ -36,15 +36,6 @@ import { commitUpdateAnimationTarget } from "../animation/static-truth";
36
36
 
37
37
  import { appendExitReleaseCallback, bindExitReleaseAnimates, collectTrackedAnimates, runExitReleaseCallbacks } from "../animation/exit-release";
38
38
 
39
- function cloneAttributeSnapshot(value) {
40
- if (!isObject(value) || isArray(value)) return value;
41
- const snapshot = {};
42
- return Object.keys(value).forEach((key => {
43
- const nextValue = value[key];
44
- snapshot[key] = isObject(nextValue) && !isArray(nextValue) ? cloneAttributeSnapshot(nextValue) : nextValue;
45
- })), snapshot;
46
- }
47
-
48
39
  loadLabelComponent();
49
40
 
50
41
  export class LabelBase extends AnimateComponent {
@@ -88,7 +79,7 @@ export class LabelBase extends AnimateComponent {
88
79
  }
89
80
  labeling(textBounds, graphicBounds, position, offset) {}
90
81
  _getLabelLinePoints(text, baseMark) {
91
- return connectLineBetweenBounds(text.AABBBounds, null == baseMark ? void 0 : baseMark.AABBBounds);
82
+ return connectLineBetweenBounds(text.AABBBounds, this.getGraphicFinalLayoutBounds(baseMark));
92
83
  }
93
84
  _createLabelLine(text, baseMark) {
94
85
  const points = this._getLabelLinePoints(text, baseMark);
@@ -158,11 +149,8 @@ export class LabelBase extends AnimateComponent {
158
149
  }
159
150
  render() {
160
151
  if (this._exitReleaseState) return;
161
- if (this._prepare(), isNil(this._idToGraphic) || this._isCollectionBase && isNil(this._idToPoint)) return;
162
- const markAttributeList = [];
163
- !1 !== this._enableAnimation && this._baseMarks.forEach((mark => {
164
- markAttributeList.push(cloneAttributeSnapshot(mark.attribute)), mark.initAttributes(this.getGraphicFinalLayoutAttributes(mark));
165
- }));
152
+ if (this._finalLayoutBoundsCache = void 0, this._prepare(), isNil(this._idToGraphic) || this._isCollectionBase && isNil(this._idToPoint)) return;
153
+ this._finalLayoutBoundsCache = new Map;
166
154
  const {overlap: overlap, smartInvert: smartInvert, dataFilter: dataFilter, customLayoutFunc: customLayoutFunc, customOverlapFunc: customOverlapFunc} = this.attribute;
167
155
  let data = this.attribute.data;
168
156
  if (isFunction(dataFilter) && (data = dataFilter(data)), data && data.length) {
@@ -183,9 +171,7 @@ export class LabelBase extends AnimateComponent {
183
171
  labels && labels.length && labels.forEach((label => {
184
172
  this._bindEvent(label), this._setStatesOfText(label);
185
173
  })), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels),
186
- !1 !== this._enableAnimation && this._baseMarks.forEach(((mark, index) => {
187
- mark.initAttributes(markAttributeList[index]);
188
- }));
174
+ this._finalLayoutBoundsCache = void 0;
189
175
  }
190
176
  _bindEvent(target) {
191
177
  if (this.attribute.disableTriggerEvent) return;
@@ -252,6 +238,24 @@ export class LabelBase extends AnimateComponent {
252
238
  var _a;
253
239
  return !!(null === (_a = null == graphic ? void 0 : graphic.context) || void 0 === _a ? void 0 : _a.finalAttrs);
254
240
  }
241
+ shouldUseGraphicFinalLayoutAttributes(graphic) {
242
+ var _a;
243
+ return !!graphic && (!!(null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.animationState) || this.hasGraphicContextFinalLayoutAttributes(graphic));
244
+ }
245
+ getGraphicFinalLayoutBounds(graphic) {
246
+ var _a, _b;
247
+ if (!graphic) return;
248
+ const useFinalAttrs = this.shouldUseGraphicFinalLayoutAttributes(graphic), graphicAttrs = useFinalAttrs ? this.getGraphicFinalLayoutAttributes(graphic) : graphic.attribute;
249
+ if (!1 === (null == graphicAttrs ? void 0 : graphicAttrs.visible)) return;
250
+ if (!useFinalAttrs) return graphic.AABBBounds;
251
+ const cachedBounds = null === (_a = this._finalLayoutBoundsCache) || void 0 === _a ? void 0 : _a.get(graphic);
252
+ if (cachedBounds) return cachedBounds;
253
+ const clonedGraphic = graphic.clone();
254
+ clonedGraphic.initAttributes(Object.assign(Object.assign({}, clonedGraphic.attribute), graphicAttrs));
255
+ const bounds = clonedGraphic.AABBBounds;
256
+ return null === (_b = this._finalLayoutBoundsCache) || void 0 === _b || _b.set(graphic, bounds),
257
+ bounds;
258
+ }
255
259
  _initText(data = []) {
256
260
  const {textStyle: textStyle = {}} = this.attribute, labels = [];
257
261
  for (let i = 0; i < data.length; i++) {
@@ -353,7 +357,8 @@ export class LabelBase extends AnimateComponent {
353
357
  var _a;
354
358
  const {avoidBaseMark: avoidBaseMark, strategy: strategy = [], hideOnHit: hideOnHit = !0, clampForce: clampForce = !0, avoidMarks: avoidMarks = [], overlapPadding: overlapPadding, hideOnOverflow: hideOnOverflow = !1} = option, result = [], checkBounds = strategy.some((s => "bound" === s.type));
355
359
  avoidBaseMark && (null === (_a = this._baseMarks) || void 0 === _a || _a.forEach((mark => {
356
- mark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, mark.AABBBounds, !0));
360
+ const markBounds = this.getGraphicFinalLayoutBounds(mark);
361
+ markBounds && bitmap.setRange(boundToRange(bmpTool, markBounds, !0));
357
362
  }))), avoidMarks.length > 0 && avoidMarks.forEach((avoid => {
358
363
  isString(avoid) ? getNoneGroupMarksByName(this.getRootNode(), avoid).forEach((avoidMark => {
359
364
  avoidMark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, avoidMark.AABBBounds, !0));
@@ -368,7 +373,7 @@ export class LabelBase extends AnimateComponent {
368
373
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
369
374
  continue;
370
375
  }
371
- if (checkBounds && baseMark && baseMark.AABBBounds && this._canPlaceInside(text.AABBBounds, baseMark.AABBBounds)) {
376
+ if (checkBounds && baseMark && this._canPlaceInside(text.AABBBounds, this.getGraphicFinalLayoutBounds(baseMark))) {
372
377
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
373
378
  continue;
374
379
  }
@@ -394,14 +399,15 @@ export class LabelBase extends AnimateComponent {
394
399
  return result;
395
400
  }
396
401
  isMarkInsideRect(baseMark, bmpTool) {
402
+ if (!baseMark) return !1;
397
403
  const {left: left, right: right, top: top, bottom: bottom} = bmpTool.padding, rect = {
398
404
  x1: -left,
399
405
  x2: bmpTool.width + right,
400
406
  y1: -top,
401
407
  y2: bmpTool.height + bottom
402
- }, bounds = baseMark.AABBBounds;
403
- if (0 !== bounds.width() && 0 !== bounds.height()) return isRectIntersect(baseMark.AABBBounds, rect, !0);
404
- const {attribute: attribute} = baseMark;
408
+ }, bounds = this.getGraphicFinalLayoutBounds(baseMark);
409
+ if (bounds && 0 !== bounds.width() && 0 !== bounds.height()) return isRectIntersect(bounds, rect, !0);
410
+ const attribute = this.shouldUseGraphicFinalLayoutAttributes(baseMark) ? this.getGraphicFinalLayoutAttributes(baseMark) : baseMark.attribute;
405
411
  if ("rect" === baseMark.type) {
406
412
  const {x: x, x1: x1, y: y, y1: y1} = attribute;
407
413
  return pointInRect({
@@ -419,17 +425,10 @@ export class LabelBase extends AnimateComponent {
419
425
  if (baseMarkGroupName) return this.getRootNode().find((node => node.name === baseMarkGroupName), !0);
420
426
  }
421
427
  getGraphicBounds(graphic, point = {}, position) {
422
- var _a;
423
428
  if (graphic) {
424
- if (!1 !== graphic.attribute.visible) {
425
- if ((null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.animationState) || this.hasGraphicContextFinalLayoutAttributes(graphic)) {
426
- const clonedGraphic = graphic.clone();
427
- return Object.assign(clonedGraphic.attribute, this.getGraphicFinalLayoutAttributes(graphic)),
428
- clonedGraphic.AABBBounds;
429
- }
430
- return graphic.AABBBounds;
431
- }
432
- const {x: x, y: y} = graphic.attribute;
429
+ const graphicAttrs = this.shouldUseGraphicFinalLayoutAttributes(graphic) ? this.getGraphicFinalLayoutAttributes(graphic) : graphic.attribute;
430
+ if (!1 !== graphicAttrs.visible) return this.getGraphicFinalLayoutBounds(graphic);
431
+ const {x: x, y: y} = graphicAttrs;
433
432
  return {
434
433
  x1: x,
435
434
  x2: x,
@@ -570,7 +569,7 @@ export class LabelBase extends AnimateComponent {
570
569
  const firstStopColor = null === (_g = null === (_f = backgroundColor.stops) || void 0 === _f ? void 0 : _f[0]) || void 0 === _g ? void 0 : _g.color;
571
570
  firstStopColor && (backgroundColor = firstStopColor, foregroundColor = firstStopColor);
572
571
  }
573
- const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode), similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor, isInside = this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds), isIntersect = !isInside && label.AABBBounds && baseMark.AABBBounds && baseMark.AABBBounds.intersects(label.AABBBounds);
572
+ const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode), similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor, baseMarkBounds = this.getGraphicFinalLayoutBounds(baseMark), isInside = this._canPlaceInside(label.AABBBounds, baseMarkBounds), isIntersect = !isInside && label.AABBBounds && baseMarkBounds && baseMarkBounds.intersects(label.AABBBounds);
574
573
  if (isInside || outsideEnable || isIntersect && "inside" === interactInvertType) {
575
574
  const fill = smartInvertStrategy(fillStrategy, backgroundColor, invertColor, similarColor);
576
575
  if (fill && label.setAttributes({