@visactor/vchart 1.13.23-alpha.1 → 1.13.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.
@@ -56,37 +56,41 @@ class Title extends base_component_1.BaseComponent {
56
56
  };
57
57
  }
58
58
  _getTitleAttrs() {
59
- var _a, _b, _c, _d, _e, _f, _g, _h;
59
+ var _a, _b, _c, _d, _e, _f;
60
60
  if (!1 === this._spec.visible) return {
61
61
  visible: !1
62
62
  };
63
63
  const layoutRect = this.getLayoutRect(), titleWidth = (0, space_1.calcLayoutNumber)(this._spec.width, layoutRect.width, null, layoutRect.width), titleMaxWidth = (0,
64
- space_1.calcLayoutNumber)(this._spec.maxWidth, layoutRect.width, null, layoutRect.width), maxWidth = Math.max(Math.min(titleWidth, titleMaxWidth, layoutRect.width), 0), attrs = Object.assign(Object.assign({}, (0,
64
+ space_1.calcLayoutNumber)(this._spec.maxWidth, layoutRect.width, null, layoutRect.width), maxWidth = Math.max(Math.min(titleWidth, titleMaxWidth, layoutRect.width), 0), hasText = (0,
65
+ vutils_1.isValid)(this._spec.text) && "" !== this._spec.text, hasSubtext = (0, vutils_1.isValid)(this._spec.subtext) && "" !== this._spec.subtext, attrs = Object.assign(Object.assign({}, (0,
65
66
  vutils_1.pickWithout)(this._spec, [ "padding" ])), {
66
67
  textType: null !== (_a = this._spec.textType) && void 0 !== _a ? _a : "text",
67
- text: null !== (_b = this._spec.text) && void 0 !== _b ? _b : "",
68
- subtextType: null !== (_c = this._spec.subtextType) && void 0 !== _c ? _c : "text",
69
- subtext: null !== (_d = this._spec.subtext) && void 0 !== _d ? _d : "",
70
- x: null !== (_e = this._spec.x) && void 0 !== _e ? _e : 0,
71
- y: null !== (_f = this._spec.y) && void 0 !== _f ? _f : 0,
68
+ text: hasText ? this._spec.text : void 0,
69
+ subtextType: null !== (_b = this._spec.subtextType) && void 0 !== _b ? _b : "text",
70
+ subtext: hasSubtext ? this._spec.subtext : void 0,
71
+ x: null !== (_c = this._spec.x) && void 0 !== _c ? _c : 0,
72
+ y: null !== (_d = this._spec.y) && void 0 !== _d ? _d : 0,
72
73
  height: this._spec.height,
73
74
  minWidth: this._spec.minWidth,
74
75
  maxWidth: maxWidth,
75
76
  minHeight: this._spec.minHeight,
76
77
  maxHeight: this._spec.maxHeight,
77
78
  padding: this._spec.innerPadding,
78
- align: null !== (_g = this._spec.align) && void 0 !== _g ? _g : "left",
79
- verticalAlign: null !== (_h = this._spec.verticalAlign) && void 0 !== _h ? _h : "top",
79
+ align: null !== (_e = this._spec.align) && void 0 !== _e ? _e : "left",
80
+ verticalAlign: null !== (_f = this._spec.verticalAlign) && void 0 !== _f ? _f : "top",
80
81
  textStyle: Object.assign({
81
- width: maxWidth,
82
82
  maxLineWidth: maxWidth
83
83
  }, this._spec.textStyle),
84
84
  subtextStyle: Object.assign({
85
85
  maxLineWidth: maxWidth
86
86
  }, this._spec.subtextStyle)
87
87
  });
88
- return (0, vutils_1.isValid)(this._spec.width) && (attrs.textStyle.width = Math.max(titleWidth, layoutRect.width),
89
- attrs.subtextStyle.width = attrs.textStyle.width), attrs;
88
+ if (hasText && (attrs.textStyle.width = maxWidth), hasSubtext && (attrs.subtextStyle.width = maxWidth),
89
+ (0, vutils_1.isValid)(this._spec.width)) {
90
+ const clampedWidth = Math.max(Math.min(titleWidth, layoutRect.width), 0);
91
+ hasText ? attrs.textStyle.width = clampedWidth : delete attrs.textStyle.width, hasSubtext && (attrs.subtextStyle.width = clampedWidth);
92
+ }
93
+ return attrs;
90
94
  }
91
95
  _createOrUpdateTitleComponent(attrs) {
92
96
  if (this._titleComponent) (0, vutils_1.isEqual)(attrs, this._cacheAttrs) || this._titleComponent.setAttributes(attrs); else {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/title/title.ts"],"names":[],"mappings":";;;AAAA,kDAAkE;AAClE,gDAA6C;AAI7C,4CAAmE;AACnE,2DAAuD;AAGvD,4CAAsD;AAEtD,qEAAwE;AAMxE,6CAAgF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AAlLQ,UAAI,GAAG,wBAAiB,CAAC,KAAK,CAAC;AAE/B,aAAO,GAAG,wBAAiB,CAAC,KAAK,CAAC;AAkLpC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,iBAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB","file":"title.js","sourcesContent":["import { LayoutLevel, LayoutZIndex } from '../../constant/layout';\nimport { Factory } from '../../core/factory';\nimport type { IModelSpecInfo } from '../../model/interface';\nimport type { IRegion } from '../../region/interface';\nimport type { IPoint, IOrientType, ILayoutType, ILayoutRect } from '../../typings';\nimport { calcLayoutNumber, isValidOrient } from '../../util/space';\nimport { BaseComponent } from '../base/base-component';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IComponentOption } from '../interface';\nimport { ComponentTypeEnum } from '../interface/type';\nimport type { ITitle, ITitleSpec } from './interface';\nimport { Title as TitleComponents } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport type { TitleAttrs } from '@visactor/vrender-components';\nimport type { IGraphic, IGroup, INode } from '@visactor/vrender-core';\nimport type { Maybe } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { isEqual, isValidNumber, pickWithout, isValid } from '@visactor/vutils';\nimport { getSpecInfo } from '../util';\n\nexport class Title<T extends ITitleSpec = ITitleSpec> extends BaseComponent<T> implements ITitle {\n static type = ComponentTypeEnum.title;\n type = ComponentTypeEnum.title;\n static specKey = ComponentTypeEnum.title;\n specKey: string = ComponentTypeEnum.title;\n\n layoutType: ILayoutType = 'normal';\n layoutZIndex: number = LayoutZIndex.Title;\n layoutLevel: number = LayoutLevel.Title;\n\n protected _orient: IOrientType = 'top';\n\n private _titleComponent: TitleComponents;\n private _cacheAttrs: TitleAttrs;\n\n get orient() {\n return this._orient;\n }\n\n constructor(spec: T, options: IComponentOption) {\n super(spec, options);\n this._orient = isValidOrient(spec.orient) ? spec.orient : 'top';\n }\n\n initLayout(): void {\n super.initLayout();\n this._layout && (this._layout.layoutOrient = this._orient);\n }\n\n static getSpecInfo(chartSpec: any): Maybe<IModelSpecInfo[]> {\n return getSpecInfo<ITitleSpec>(chartSpec, this.specKey, ComponentTypeEnum.title, (s: ITitleSpec) => {\n return s.visible !== false;\n });\n }\n\n onRender(ctx: any): void {\n // do nothing\n }\n\n /**\n * updateSpec\n */\n _compareSpec(spec: T, prevSpec: T) {\n const result = super._compareSpec(spec, prevSpec);\n\n if (prevSpec?.orient !== spec?.orient || (prevSpec as any)?.visible !== (spec as any).visible) {\n // title 组件切换visible会影响布局,所以需要重新remake\n result.reMake = true;\n }\n\n result.change = true;\n result.reRender = true;\n return result;\n }\n\n // region\n changeRegions(regions: IRegion[]): void {\n // do nothing\n }\n\n update(ctx: IComponentOption) {\n // TODO\n }\n\n resize(ctx: IComponentOption) {\n // TODO\n }\n\n afterSetLayoutStartPoint(pos: IPoint): void {\n if (isValidNumber(pos.x)) {\n this._titleComponent && this._titleComponent.setAttribute('x', pos.x);\n }\n if (isValidNumber(pos.y)) {\n this._titleComponent && this._titleComponent.setAttribute('y', pos.y);\n }\n super.afterSetLayoutStartPoint(pos);\n }\n\n getBoundsInRect(rect: ILayoutRect) {\n let result: Partial<ILayoutRect> = {};\n this.setLayoutRect(rect);\n\n const attrs = this._getTitleAttrs();\n this._createOrUpdateTitleComponent(attrs);\n\n result = this._getTitleLayoutRect();\n const { x, y } = this.getLayoutStartPoint();\n return {\n x1: x,\n y1: y,\n x2: x + result.width,\n y2: y + result.height\n };\n }\n\n private _getTitleLayoutRect() {\n const titleBounds = this._titleComponent.AABBBounds;\n const width = this._spec.width ? this._spec.width : isValidNumber(titleBounds.width()) ? titleBounds.width() : 0;\n const height = this._spec.height\n ? this._spec.height\n : isValidNumber(titleBounds.height())\n ? titleBounds.height()\n : 0;\n return {\n width,\n height\n };\n }\n\n private _getTitleAttrs() {\n // 当 width 小于 0 时,设置为 0,负数场景容易引起不可预知的问题\n if (this._spec.visible === false) {\n return { visible: false };\n }\n const layoutRect = this.getLayoutRect();\n const titleWidth = calcLayoutNumber(this._spec.width, layoutRect.width, null, layoutRect.width);\n const titleMaxWidth = calcLayoutNumber(this._spec.maxWidth, layoutRect.width, null, layoutRect.width);\n const maxWidth = Math.max(Math.min(titleWidth, titleMaxWidth, layoutRect.width), 0);\n\n const attrs = {\n ...(pickWithout(this._spec, ['padding']) as any),\n textType: this._spec.textType ?? 'text',\n text: this._spec.text ?? '',\n subtextType: this._spec.subtextType ?? 'text',\n subtext: this._spec.subtext ?? '',\n x: this._spec.x ?? 0,\n y: this._spec.y ?? 0,\n height: this._spec.height,\n minWidth: this._spec.minWidth,\n maxWidth,\n minHeight: this._spec.minHeight,\n maxHeight: this._spec.maxHeight,\n padding: this._spec.innerPadding,\n align: this._spec.align ?? 'left',\n verticalAlign: this._spec.verticalAlign ?? 'top',\n textStyle: {\n width: maxWidth,\n maxLineWidth: maxWidth,\n ...this._spec.textStyle\n },\n subtextStyle: {\n maxLineWidth: maxWidth,\n ...this._spec.subtextStyle\n }\n } as TitleAttrs;\n\n if (isValid(this._spec.width)) {\n attrs.textStyle.width = Math.max(titleWidth, layoutRect.width);\n attrs.subtextStyle.width = attrs.textStyle.width;\n }\n return attrs;\n }\n\n private _createOrUpdateTitleComponent(attrs: TitleAttrs): TitleComponents {\n if (this._titleComponent) {\n if (!isEqual(attrs, this._cacheAttrs)) {\n this._titleComponent.setAttributes(attrs);\n }\n } else {\n const container = this.getContainer();\n const title = new TitleComponents(attrs);\n title.name = 'title';\n container.add(title as unknown as INode);\n this._titleComponent = title;\n // 代理 title 组件上的事件\n title.on('*', (event: any, type: string) => this._delegateEvent(title as unknown as IGraphic, event, type));\n }\n this._cacheAttrs = attrs;\n return this._titleComponent;\n }\n\n protected _getNeedClearVRenderComponents(): IGraphic[] {\n return [this._titleComponent] as unknown as IGroup[];\n }\n\n clear(): void {\n super.clear();\n this._cacheAttrs = null;\n }\n}\n\nexport const registerTitle = () => {\n Factory.registerComponent(Title.type, Title);\n};\n"]}
1
+ {"version":3,"sources":["../src/component/title/title.ts"],"names":[],"mappings":";;;AAAA,kDAAkE;AAClE,gDAA6C;AAI7C,4CAAmE;AACnE,2DAAuD;AAGvD,4CAAsD;AAEtD,qEAAwE;AAMxE,6CAAgF;AAChF,kCAAsC;AAEtC,MAAa,KAAyC,SAAQ,8BAAgB;IAe5E,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,YAAY,IAAO,EAAE,OAAyB;QAC5C,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAlBvB,SAAI,GAAG,wBAAiB,CAAC,KAAK,CAAC;QAE/B,YAAO,GAAW,wBAAiB,CAAC,KAAK,CAAC;QAE1C,eAAU,GAAgB,QAAQ,CAAC;QACnC,iBAAY,GAAW,qBAAY,CAAC,KAAK,CAAC;QAC1C,gBAAW,GAAW,oBAAW,CAAC,KAAK,CAAC;QAE9B,YAAO,GAAgB,KAAK,CAAC;QAWrC,IAAI,CAAC,OAAO,GAAG,IAAA,qBAAa,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;IAClE,CAAC;IAED,UAAU;QACR,KAAK,CAAC,UAAU,EAAE,CAAC;QACnB,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,SAAc;QAC/B,OAAO,IAAA,kBAAW,EAAa,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,wBAAiB,CAAC,KAAK,EAAE,CAAC,CAAa,EAAE,EAAE;YACjG,OAAO,CAAC,CAAC,OAAO,KAAK,KAAK,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,QAAQ,CAAC,GAAQ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EAAE;YACxB,IAAI,CAAC,IAAA,gBAAO,EAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE;gBACrC,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;aAC3C;SACF;aAAM;YACL,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YACtC,MAAM,KAAK,GAAG,IAAI,0BAAe,CAAC,KAAK,CAAC,CAAC;YACzC,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC;YACrB,SAAS,CAAC,GAAG,CAAC,KAAyB,CAAC,CAAC;YACzC,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;YAE7B,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,KAAU,EAAE,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,KAA4B,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;SAC7G;QACD,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAES,8BAA8B;QACtC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAwB,CAAC;IACvD,CAAC;IAED,KAAK;QACH,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;;AAtMH,sBAuMC;AAtMQ,UAAI,GAAG,wBAAiB,CAAC,KAAK,CAAC;AAE/B,aAAO,GAAG,wBAAiB,CAAC,KAAK,CAAC;AAsMpC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,iBAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB","file":"title.js","sourcesContent":["import { LayoutLevel, LayoutZIndex } from '../../constant/layout';\nimport { Factory } from '../../core/factory';\nimport type { IModelSpecInfo } from '../../model/interface';\nimport type { IRegion } from '../../region/interface';\nimport type { IPoint, IOrientType, ILayoutType, ILayoutRect } from '../../typings';\nimport { calcLayoutNumber, isValidOrient } from '../../util/space';\nimport { BaseComponent } from '../base/base-component';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IComponentOption } from '../interface';\nimport { ComponentTypeEnum } from '../interface/type';\nimport type { ITitle, ITitleSpec } from './interface';\nimport { Title as TitleComponents } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport type { TitleAttrs } from '@visactor/vrender-components';\nimport type { IGraphic, IGroup, INode } from '@visactor/vrender-core';\nimport type { Maybe } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { isEqual, isValidNumber, pickWithout, isValid } from '@visactor/vutils';\nimport { getSpecInfo } from '../util';\n\nexport class Title<T extends ITitleSpec = ITitleSpec> extends BaseComponent<T> implements ITitle {\n static type = ComponentTypeEnum.title;\n type = ComponentTypeEnum.title;\n static specKey = ComponentTypeEnum.title;\n specKey: string = ComponentTypeEnum.title;\n\n layoutType: ILayoutType = 'normal';\n layoutZIndex: number = LayoutZIndex.Title;\n layoutLevel: number = LayoutLevel.Title;\n\n protected _orient: IOrientType = 'top';\n\n private _titleComponent: TitleComponents;\n private _cacheAttrs: TitleAttrs;\n\n get orient() {\n return this._orient;\n }\n\n constructor(spec: T, options: IComponentOption) {\n super(spec, options);\n this._orient = isValidOrient(spec.orient) ? spec.orient : 'top';\n }\n\n initLayout(): void {\n super.initLayout();\n this._layout && (this._layout.layoutOrient = this._orient);\n }\n\n static getSpecInfo(chartSpec: any): Maybe<IModelSpecInfo[]> {\n return getSpecInfo<ITitleSpec>(chartSpec, this.specKey, ComponentTypeEnum.title, (s: ITitleSpec) => {\n return s.visible !== false;\n });\n }\n\n onRender(ctx: any): void {\n // do nothing\n }\n\n /**\n * updateSpec\n */\n _compareSpec(spec: T, prevSpec: T) {\n const result = super._compareSpec(spec, prevSpec);\n\n if (prevSpec?.orient !== spec?.orient || (prevSpec as any)?.visible !== (spec as any).visible) {\n // title 组件切换visible会影响布局,所以需要重新remake\n result.reMake = true;\n }\n\n result.change = true;\n result.reRender = true;\n return result;\n }\n\n // region\n changeRegions(regions: IRegion[]): void {\n // do nothing\n }\n\n update(ctx: IComponentOption) {\n // TODO\n }\n\n resize(ctx: IComponentOption) {\n // TODO\n }\n\n afterSetLayoutStartPoint(pos: IPoint): void {\n if (isValidNumber(pos.x)) {\n this._titleComponent && this._titleComponent.setAttribute('x', pos.x);\n }\n if (isValidNumber(pos.y)) {\n this._titleComponent && this._titleComponent.setAttribute('y', pos.y);\n }\n super.afterSetLayoutStartPoint(pos);\n }\n\n getBoundsInRect(rect: ILayoutRect) {\n let result: Partial<ILayoutRect> = {};\n this.setLayoutRect(rect);\n\n const attrs = this._getTitleAttrs();\n this._createOrUpdateTitleComponent(attrs);\n\n result = this._getTitleLayoutRect();\n const { x, y } = this.getLayoutStartPoint();\n return {\n x1: x,\n y1: y,\n x2: x + result.width,\n y2: y + result.height\n };\n }\n\n private _getTitleLayoutRect() {\n const titleBounds = this._titleComponent.AABBBounds;\n const width = this._spec.width ? this._spec.width : isValidNumber(titleBounds.width()) ? titleBounds.width() : 0;\n const height = this._spec.height\n ? this._spec.height\n : isValidNumber(titleBounds.height())\n ? titleBounds.height()\n : 0;\n return {\n width,\n height\n };\n }\n\n private _getTitleAttrs() {\n /**\n * 生成标题组件的渲染属性,统一计算宽高与对齐参数,\n * 并在仅副标题场景下避免主标题宽度影响副标题布局。\n */\n if (this._spec.visible === false) {\n return { visible: false };\n }\n const layoutRect = this.getLayoutRect();\n const titleWidth = calcLayoutNumber(this._spec.width, layoutRect.width, null, layoutRect.width);\n const titleMaxWidth = calcLayoutNumber(this._spec.maxWidth, layoutRect.width, null, layoutRect.width);\n const maxWidth = Math.max(Math.min(titleWidth, titleMaxWidth, layoutRect.width), 0);\n const hasText = isValid(this._spec.text) && this._spec.text !== '';\n const hasSubtext = isValid(this._spec.subtext) && this._spec.subtext !== '';\n\n const attrs = {\n ...(pickWithout(this._spec, ['padding']) as any),\n textType: this._spec.textType ?? 'text',\n text: hasText ? this._spec.text : undefined,\n subtextType: this._spec.subtextType ?? 'text',\n subtext: hasSubtext ? this._spec.subtext : undefined,\n x: this._spec.x ?? 0,\n y: this._spec.y ?? 0,\n height: this._spec.height,\n minWidth: this._spec.minWidth,\n maxWidth,\n minHeight: this._spec.minHeight,\n maxHeight: this._spec.maxHeight,\n padding: this._spec.innerPadding,\n align: this._spec.align ?? 'left',\n verticalAlign: this._spec.verticalAlign ?? 'top',\n textStyle: {\n maxLineWidth: maxWidth,\n ...this._spec.textStyle\n },\n subtextStyle: {\n maxLineWidth: maxWidth,\n ...this._spec.subtextStyle\n }\n } as TitleAttrs;\n\n // 仅在对应文本存在时设置 width,避免空主标题影响副标题的对齐与宽度计算\n if (hasText) {\n (attrs.textStyle as any).width = maxWidth;\n }\n if (hasSubtext) {\n (attrs.subtextStyle as any).width = maxWidth;\n }\n\n if (isValid(this._spec.width)) {\n const clampedWidth = Math.max(Math.min(titleWidth, layoutRect.width), 0);\n if (hasText) {\n (attrs.textStyle as any).width = clampedWidth;\n } else {\n // 主标题不存在时,不设置其 width\n delete (attrs.textStyle as any).width;\n }\n if (hasSubtext) {\n (attrs.subtextStyle as any).width = clampedWidth;\n }\n }\n return attrs;\n }\n\n private _createOrUpdateTitleComponent(attrs: TitleAttrs): TitleComponents {\n if (this._titleComponent) {\n if (!isEqual(attrs, this._cacheAttrs)) {\n this._titleComponent.setAttributes(attrs);\n }\n } else {\n const container = this.getContainer();\n const title = new TitleComponents(attrs);\n title.name = 'title';\n container.add(title as unknown as INode);\n this._titleComponent = title;\n // 代理 title 组件上的事件\n title.on('*', (event: any, type: string) => this._delegateEvent(title as unknown as IGraphic, event, type));\n }\n this._cacheAttrs = attrs;\n return this._titleComponent;\n }\n\n protected _getNeedClearVRenderComponents(): IGraphic[] {\n return [this._titleComponent] as unknown as IGroup[];\n }\n\n clear(): void {\n super.clear();\n this._cacheAttrs = null;\n }\n}\n\nexport const registerTitle = () => {\n Factory.registerComponent(Title.type, Title);\n};\n"]}
@@ -26,7 +26,6 @@ export declare class BaseWordCloudSeries<T extends IBaseWordCloudSeriesSpec = IB
26
26
  protected _isWordCloudShape: boolean;
27
27
  protected _wordCloudConfig?: WordCloudConfigType;
28
28
  protected _wordCloudShapeConfig?: WordCloudShapeConfigType;
29
- private _wordMeasureCache?;
30
29
  protected _padding?: IPadding;
31
30
  protected _defaultFontFamily: string;
32
31
  protected _keyWordColorCallback: (datum: Datum) => string;
@@ -64,5 +63,4 @@ export declare class BaseWordCloudSeries<T extends IBaseWordCloudSeriesSpec = IB
64
63
  onLayoutEnd(ctx: any): void;
65
64
  getActiveMarks(): IMark[];
66
65
  reInit(): void;
67
- release(): void;
68
66
  }
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.BaseWordCloudSeries = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), vutils_2 = require("@visactor/vutils"), data_1 = require("../../constant/data"), attribute_1 = require("../../constant/attribute"), env_1 = require("../../util/env"), config_1 = require("./config"), measure_cache_1 = require("./measure-cache"), utils_1 = require("../../animation/utils"), word_cloud_1 = require("../../constant/word-cloud"), base_series_1 = require("../base/base-series"), color_ordinal_scale_1 = require("../../scale/color-ordinal-scale"), constant_1 = require("./constant"), factory_1 = require("../../core/factory"), vscale_1 = require("@visactor/vscale");
7
+ const vutils_1 = require("@visactor/vutils"), vutils_2 = require("@visactor/vutils"), data_1 = require("../../constant/data"), attribute_1 = require("../../constant/attribute"), env_1 = require("../../util/env"), config_1 = require("./config"), utils_1 = require("../../animation/utils"), word_cloud_1 = require("../../constant/word-cloud"), base_series_1 = require("../base/base-series"), color_ordinal_scale_1 = require("../../scale/color-ordinal-scale"), constant_1 = require("./constant"), factory_1 = require("../../core/factory"), vscale_1 = require("@visactor/vscale");
8
8
 
9
9
  class BaseWordCloudSeries extends base_series_1.BaseSeries {
10
10
  constructor() {
@@ -45,14 +45,12 @@ class BaseWordCloudSeries extends base_series_1.BaseSeries {
45
45
  fillingRotateAngles: config_1.DEFAULT_ROTATE_ANGLES,
46
46
  layoutMode: "default"
47
47
  }, this._spec.wordCloudShapeConfig), this._isWordCloudShape = !config_1.SHAPE_TYPE.includes(this._maskShape) && ![ "fast", "grid", "cloud" ].includes(this._wordCloudConfig.layoutMode),
48
- this._defaultFontFamily = this._option.getTheme().fontFamily, this._wordMeasureCache || (this._wordMeasureCache = new measure_cache_1.WordMeasureCache(1e3));
48
+ this._defaultFontFamily = this._option.getTheme().fontFamily;
49
49
  }
50
50
  initData() {
51
51
  var _a, _b;
52
52
  super.initData(), null === (_b = null === (_a = this.getViewData()) || void 0 === _a ? void 0 : _a.target) || void 0 === _b || _b.addListener("change", (() => {
53
- var _a;
54
- null === (_a = this._wordMeasureCache) || void 0 === _a || _a.clear(), this._dataChange = !0,
55
- this.compile();
53
+ this._dataChange = !0, this.compile();
56
54
  }));
57
55
  }
58
56
  initMark() {
@@ -196,7 +194,6 @@ class BaseWordCloudSeries extends base_series_1.BaseSeries {
196
194
  var _a, _b, _c, _d, _e, _f;
197
195
  const fillingWordStyleSpec = null !== (_b = null === (_a = this._spec.fillingWord) || void 0 === _a ? void 0 : _a.style) && void 0 !== _b ? _b : {}, wordCloudShapeConfig = null !== (_c = this._wordCloudShapeConfig) && void 0 !== _c ? _c : {};
198
196
  return Object.assign(Object.assign(Object.assign({}, wordCloudShapeConfig), this._getCommonTransformOptions()), {
199
- measureCache: this._wordMeasureCache,
200
197
  rotateList: this._rotateAngles,
201
198
  fillingRotateList: wordCloudShapeConfig.fillingRotateAngles,
202
199
  fillingFontFamily: (0, vutils_2.isValid)(wordCloudShapeConfig.fillingFontFamilyField) ? {
@@ -252,14 +249,8 @@ class BaseWordCloudSeries extends base_series_1.BaseSeries {
252
249
  return [ this._wordMark ];
253
250
  }
254
251
  reInit() {
255
- var _a;
256
252
  super.reInit(), this._keyWordColorCallback && (this._keyWordColorCallback = null),
257
- this._fillingColorCallback && (this._fillingColorCallback = null), null === (_a = this._wordMeasureCache) || void 0 === _a || _a.clear();
258
- }
259
- release() {
260
- var _a;
261
- super.release(), null === (_a = this._wordMeasureCache) || void 0 === _a || _a.clear(),
262
- this._wordMeasureCache = void 0;
253
+ this._fillingColorCallback && (this._fillingColorCallback = null);
263
254
  }
264
255
  }
265
256
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/series/word-cloud/base.ts"],"names":[],"mappings":";;;AAEA,6CAAkE;AAClE,6CAA2C;AAC3C,8CAAsG;AACtG,wDAA0D;AAG1D,wCAA+C;AAC/C,qCAWkB;AAOlB,mDAAmD;AAEnD,iDAA6E;AAC7E,0DAA4D;AAE5D,qDAAiD;AACjD,yEAAoE;AACpE,yCAAiD;AAEjD,gDAA6C;AAE7C,6CAA+C;AAK/C,MAAa,mBAAmF,SAAQ,wBAAa;IAArH;;QAmBY,mBAAc,GAA+B,CAAC,8BAAqB,EAAE,8BAAqB,CAAC,CAAC;QAU5F,sBAAiB,GAAY,KAAK,CAAC;QAYnC,gBAAW,GAAY,IAAI,CAAC;QAE5B,2BAAsB,GAAG,CAAC,MAAyB,EAAE,QAAiB,EAAE,EAAE;YAClF,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAC5B,CAAC,CAAC;QAqNF,iBAAY,GAAG,CAAC,KAAY,EAAE,EAAE;YAC9B,IAAI,KAAK,CAAC,aAAa,EAAE;gBACvB,IAAI,CAAC,IAAI,CAAC,qBAAqB,IAAI,IAAI,CAAC,WAAW,EAAE;oBAEnD,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC,oBAAoB;wBAC1E,CAAC,CAAC,CAAC,KAAY,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,oBAAoB,CAAC;wBAC1E,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,EAAE,IAAI,CAAC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AI,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM;;QACJ,KAAK,CAAC,MAAM,EAAE,CAAC;QACf,IAAI,IAAI,CAAC,qBAAqB,EAAE;YAC9B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;SACnC;QAED,IAAI,IAAI,CAAC,qBAAqB,EAAE;YAC9B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;SACnC;QAED,MAAA,IAAI,CAAC,iBAAiB,0CAAE,KAAK,EAAE,CAAC;IAClC,CAAC;IAED,OAAO;;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,MAAA,IAAI,CAAC,iBAAiB,0CAAE,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;IACrC,CAAC;;AAreH,kDAseC;AAreiB,wBAAI,GAAkB,8BAAmB,CAAC","file":"base.js","sourcesContent":["/* eslint-disable no-duplicate-imports */\nimport type { IPadding } from '@visactor/vutils';\nimport { isNil, isObject, isValidNumber } from '@visactor/vutils';\nimport { isValid } from '@visactor/vutils';\nimport { DEFAULT_DATA_INDEX, DEFAULT_DATA_KEY, DEFAULT_DATA_SERIES_FIELD } from '../../constant/data';\nimport { AttributeLevel } from '../../constant/attribute';\nimport type { SeriesMarkMap } from '../interface';\nimport { SeriesMarkNameEnum } from '../interface/type';\nimport { isTrueBrowser } from '../../util/env';\nimport {\n DEFAULT_DRAW_OUT_OF_BOUND,\n DEFAULT_FONTSIZE_RANGE,\n DEFAULT_FONT_PADDING,\n DEFAULT_FONT_WEIGHT_RANGE,\n DEFAULT_MASK_SHAPE,\n DEFAULT_MIN_FONT_SIZE,\n DEFAULT_RANDOM,\n DEFAULT_ROTATE_ANGLES,\n DEFAULT_ZOOM_TO_FIT,\n SHAPE_TYPE\n} from './config';\nimport type {\n IWordCloudSeriesSpec,\n WordCloudConfigType,\n WordCloudShapeConfigType,\n WordCloudShapeType\n} from './interface';\nimport { WordMeasureCache } from './measure-cache';\nimport type { Datum, IMarkSpec, IPoint, ITextMarkSpec } from '../../typings';\nimport { animationConfig, userAnimationConfig } from '../../animation/utils';\nimport { WORD_CLOUD_TEXT } from '../../constant/word-cloud';\nimport type { ICompilableMark } from '../../compile/mark';\nimport { BaseSeries } from '../base/base-series';\nimport { ColorOrdinalScale } from '../../scale/color-ordinal-scale';\nimport { wordCloudSeriesMark } from './constant';\nimport type { IStateAnimateSpec } from '../../animation/spec';\nimport { Factory } from '../../core/factory';\nimport type { IMark, IRectMark, ITextMark } from '../../mark/interface';\nimport { LinearScale } from '@visactor/vscale';\nimport type { GeometricMaskShape, TextShapeMask } from '@visactor/vgrammar-util';\n\nexport type IBaseWordCloudSeriesSpec = Omit<IWordCloudSeriesSpec, 'type'> & { type: string };\n\nexport class BaseWordCloudSeries<T extends IBaseWordCloudSeriesSpec = IBaseWordCloudSeriesSpec> extends BaseSeries<T> {\n static readonly mark: SeriesMarkMap = wordCloudSeriesMark;\n\n protected _nameField: string;\n protected _valueField?: string;\n setValueField(field: string) {\n if (isValid(field)) {\n this._valueField = field;\n }\n }\n\n protected _colorMode: 'linear' | 'ordinal';\n protected _colorList: string[];\n protected _rotateAngles?: number[];\n protected _fontWeightRange?: [number, number];\n protected _textField?: string;\n protected _maskCanvas?: HTMLCanvasElement;\n protected _maskMark?: IRectMark;\n\n protected _fontSizeRange?: [number, number] | 'auto' = [DEFAULT_MIN_FONT_SIZE, DEFAULT_MIN_FONT_SIZE];\n setFontSizeRange(fontSizeRange: [number, number] | 'auto') {\n if (isValid(fontSizeRange)) {\n this._fontSizeRange = fontSizeRange;\n } else {\n this._fontSizeRange = DEFAULT_FONTSIZE_RANGE;\n }\n }\n\n protected _maskShape?: string | WordCloudShapeType | TextShapeMask | GeometricMaskShape;\n protected _isWordCloudShape: boolean = false;\n\n protected _wordCloudConfig?: WordCloudConfigType;\n protected _wordCloudShapeConfig?: WordCloudShapeConfigType;\n\n private _wordMeasureCache?: WordMeasureCache;\n\n protected _padding?: IPadding;\n protected _defaultFontFamily: string;\n\n protected _keyWordColorCallback: (datum: Datum) => string;\n protected _fillingColorCallback: (datum: Datum) => string;\n protected _dataChange: boolean = true;\n\n protected handleMaskCanvasUpdate = (canvas: HTMLCanvasElement, imageUrl?: string) => {\n this._maskCanvas = canvas;\n };\n /**\n * @override\n */\n setAttrFromSpec() {\n super.setAttrFromSpec();\n // series布局相关\n this._padding = this._option.getChart().padding;\n\n // 普通词云 & 形状词云 共有spec相关\n this._nameField = this._spec.nameField;\n this._colorMode = this._spec.colorMode ?? 'ordinal';\n this._colorList = this._spec.colorList;\n this.setValueField(this._spec.valueField);\n this._fontWeightRange = this._spec.fontWeightRange ?? DEFAULT_FONT_WEIGHT_RANGE;\n this._rotateAngles = this._spec.rotateAngles ?? DEFAULT_ROTATE_ANGLES;\n this.setFontSizeRange(this._spec.fontSizeRange);\n this._maskShape = this._spec.maskShape ?? DEFAULT_MASK_SHAPE;\n this._textField = this._spec.word?.formatMethod ? WORD_CLOUD_TEXT : this._nameField;\n const wordCloudConfig = this._spec.wordCloudConfig;\n // 普通词云spec相关\n this._wordCloudConfig = {\n drawOutOfBound: DEFAULT_DRAW_OUT_OF_BOUND,\n layoutMode: 'default',\n zoomToFit: DEFAULT_ZOOM_TO_FIT,\n ...this._spec.wordCloudConfig\n };\n\n if ((!wordCloudConfig || isNil(wordCloudConfig.layoutMode)) && !isTrueBrowser(this._option.mode)) {\n this._wordCloudConfig.layoutMode = 'fast';\n }\n\n // 形状词云spec相关\n this._wordCloudShapeConfig = {\n fillingSeriesField: this.getSeriesField(),\n fillingRotateAngles: DEFAULT_ROTATE_ANGLES,\n layoutMode: 'default',\n ...this._spec.wordCloudShapeConfig\n };\n\n this._isWordCloudShape =\n !SHAPE_TYPE.includes(this._maskShape as string) &&\n !['fast', 'grid', 'cloud'].includes(this._wordCloudConfig.layoutMode);\n this._defaultFontFamily = this._option.getTheme().fontFamily as string;\n\n if (!this._wordMeasureCache) {\n this._wordMeasureCache = new WordMeasureCache(1000);\n }\n }\n\n /**\n * @override\n */\n protected initData(): void {\n super.initData();\n // data改变时, 需要重新编译, 重新布局\n this.getViewData()?.target?.addListener('change', () => {\n this._wordMeasureCache?.clear();\n this._dataChange = true;\n this.compile();\n });\n }\n\n protected _wordMark: ITextMark;\n\n initMark(): void {\n if (this._spec.wordMask?.visible) {\n this._maskMark = this._createMark(BaseWordCloudSeries.mark.wordMask, { dataView: false }) as IRectMark;\n }\n\n this._wordMark = this._createMark(\n BaseWordCloudSeries.mark.word,\n {\n key: DEFAULT_DATA_KEY,\n groupKey: this._seriesField,\n isSeriesMark: true\n },\n {\n morphElementKey: this._seriesField\n }\n ) as ITextMark;\n }\n\n initMarkStyle() {\n this.initMarkStyleOfWord(this._wordMark, this._spec.word, this._spec.colorHexField, this._seriesField);\n\n if (this._maskMark) {\n this.setMarkStyle(\n this._maskMark,\n {\n width: () => {\n return this._region.getLayoutRect().width;\n },\n height: () => {\n return this._region.getLayoutRect().height;\n },\n background: () => {\n return this._maskCanvas;\n }\n },\n 'normal',\n AttributeLevel.Series\n );\n }\n }\n\n initMarkStyleOfWord(\n wordMark: ITextMark,\n wordSpec?: IMarkSpec<ITextMarkSpec>,\n colorHexField?: string,\n seriesField?: string,\n isFillingWord?: boolean\n ): void {\n if (!wordMark) {\n return;\n }\n this.setMarkStyle(\n wordMark,\n {\n text: (wordSpec as any)?.formatMethod\n ? (datum: Datum) => {\n return (wordSpec as any).formatMethod(datum);\n }\n : (datum: Datum) => datum[this._textField],\n x: (datum: Datum) => datum.x,\n y: (datum: Datum) => datum.y,\n fontSize: (datum: Datum) => datum.fontSize,\n fontStyle: (datum: Datum) => datum.fontStyle,\n\n angle: (datum: Datum) => datum.angle,\n visible: (datum: Datum) => datum.visible\n },\n 'normal',\n AttributeLevel.Series\n );\n this.setMarkStyle(\n wordMark,\n {\n fill: wordSpec?.style?.fill ?? this.getWordColor,\n // style和field相关的配置都已经传给vgrammar, 所以这里直接拿结果就可以\n fontWeight: (datum: Datum) => datum.fontWeight,\n fontFamily: (datum: Datum) => datum.fontFamily\n },\n 'normal',\n AttributeLevel.User_Mark\n );\n }\n\n protected initTooltip() {\n super.initTooltip();\n\n this._wordMark && this._tooltipHelper.activeTriggerSet.mark.add(this._wordMark);\n }\n\n initAnimation() {\n [this._wordMark].forEach(mark => {\n if (mark) {\n const appearPreset = (this._spec?.animationAppear as IStateAnimateSpec<any>)?.preset;\n const params = {\n animationConfig: () => mark.getAnimationConfig()?.appear?.[0]\n };\n mark.setAnimationConfig(\n animationConfig(\n Factory.getAnimationInKey('wordCloud')(params, appearPreset),\n userAnimationConfig(SeriesMarkNameEnum.word, this._spec, this._markAttributeContext)\n )\n );\n }\n });\n }\n\n protected getWordOrdinalColorScale(field: string, isFillingWord: boolean) {\n const colorList = isFillingWord ? this._wordCloudShapeConfig.fillingColorList : this._colorList;\n const colorDomain = field ? this.getViewData()?.latestData.map((datum: Datum) => datum[field]) : [];\n const colorRange = colorList ?? this._option.globalScale.getScale('color')?.range() ?? this._getDataScheme();\n return new ColorOrdinalScale().domain(colorDomain).range?.(colorRange);\n }\n\n protected initColorCallback(field: string, isFillingWord: boolean) {\n if (this._colorMode === 'ordinal') {\n const scale = this.getWordOrdinalColorScale(field, isFillingWord);\n return (datum: Datum) => {\n return scale.scale(datum[field ?? DEFAULT_DATA_SERIES_FIELD]);\n };\n }\n\n const colorList =\n (isFillingWord ? this._colorList : this._wordCloudShapeConfig.fillingColorList) ??\n this._option.globalScale.getScale('color').range();\n\n if (colorList.length === 1) {\n return (datum: Datum) => colorList[0];\n }\n\n if (this._valueField) {\n const stats = this.getRawDataStatisticsByField(this._valueField, true);\n if (stats.min === stats.max) {\n return colorList[0];\n }\n const scale = new LinearScale().domain([stats.min, stats.max]).range(colorList);\n\n return (datum: Datum) => {\n return scale.scale(datum[this._valueField]);\n };\n }\n\n const scale = new LinearScale().domain([0, this.getViewData()?.latestData?.length ?? 1]).range(colorList);\n\n return (datum: Datum) => {\n return scale.scale(datum[DEFAULT_DATA_INDEX]);\n };\n }\n\n getWordColor = (datum: Datum) => {\n if (datum.isFillingWord) {\n if (!this._fillingColorCallback || this._dataChange) {\n // 如果updateData数据变更了, 颜色映射也需要重新计算\n this._fillingColorCallback = this._wordCloudShapeConfig.fillingColorHexField\n ? (datum: Datum) => datum[this._wordCloudShapeConfig.fillingColorHexField]\n : this.initColorCallback(this._wordCloudShapeConfig.fillingSeriesField, true);\n }\n\n return this._fillingColorCallback(datum);\n }\n\n if (!this._keyWordColorCallback || this._dataChange) {\n // 如果updateData数据变更了, 颜色映射也需要重新计算\n this._keyWordColorCallback = this._spec.colorHexField\n ? datum => datum[this._spec.colorHexField]\n : this.initColorCallback(this._seriesField, false);\n }\n\n return this._keyWordColorCallback(datum);\n };\n\n private _calculateFontWeight = (datum: Datum) => {\n const stats = this.getRawDataStatisticsByField(this._valueField, true);\n\n if (stats.min === stats.max) {\n return this._fontWeightRange[0];\n }\n\n return (\n this._fontWeightRange[0] +\n ((this._fontWeightRange[this._fontWeightRange.length - 1] - this._fontWeightRange[0]) *\n (datum[this._valueField] - stats.min)) /\n (stats.max - stats.min)\n );\n };\n\n compile(): void {\n super.compile();\n const { width, height } = this._region.getLayoutRect();\n // 非正常尺寸下不进行布局\n if (!isValidNumber(width) || !isValidNumber(height) || !(height > 0 && width > 0)) {\n return;\n }\n\n const product = (this._wordMark as ICompilableMark).getProduct();\n\n if (product) {\n const wordCloudTransforms: any[] = [];\n\n // 词云 transform\n if (!this._isWordCloudShape) {\n wordCloudTransforms.push({\n type: 'wordcloud',\n ...this._wordCloudTransformOption()\n });\n }\n // 形状词云 transform\n else {\n wordCloudTransforms.push({\n type: 'wordcloudShape',\n // 形状词云中必须要传入dataIndexKey, 否则填充词无法绘制\n ...this._wordCloudShapeTransformOption()\n });\n }\n\n // 挂到mark的transform上\n product.transform(wordCloudTransforms);\n }\n }\n\n protected _getCommonTransformOptions(): any {\n const { width, height } = this._region.getLayoutRect();\n const wordSpec = this._spec.word ?? {};\n const wordStyleSpec = wordSpec.style ?? {};\n\n return {\n size: [width, height],\n shape:\n isObject(this._maskShape) &&\n (this._maskShape as TextShapeMask).type === 'text' &&\n isNil((this._maskShape as TextShapeMask).fontFamily)\n ? {\n fontFamily: this._option.getTheme()?.fontFamily,\n ...this._maskShape\n }\n : this._maskShape,\n onUpdateMaskCanvas: this.handleMaskCanvasUpdate,\n dataIndexKey: DEFAULT_DATA_KEY,\n text: wordSpec.formatMethod\n ? (datum: Datum) => {\n return wordSpec.formatMethod(datum);\n }\n : { field: this._textField },\n fontSize: this._valueField ? { field: this._valueField } : this._fontSizeRange[0],\n fontSizeRange: this._fontSizeRange === 'auto' ? null : this._fontSizeRange,\n\n padding: this._spec.word?.padding ?? DEFAULT_FONT_PADDING,\n fontFamily: isValid(this._spec.fontFamilyField)\n ? { field: this._spec.fontFamilyField }\n : wordStyleSpec.fontFamily ?? this._defaultFontFamily,\n // 为了保持和旧版逻辑一致,优先级如下: spec field > mark style > default (根据valueField映射)\n fontWeight: isValid(this._spec.fontWeightField)\n ? { field: this._spec.fontWeightField }\n : isValid(wordStyleSpec.fontWeight)\n ? wordStyleSpec.fontWeight\n : isValid(this._valueField)\n ? this._calculateFontWeight\n : 'normal',\n fontStyle: isValid(this._spec.fontStyleField) ? { field: this._spec.fontStyleField } : wordStyleSpec.fontStyle\n };\n }\n\n protected _wordCloudTransformOption(): Object {\n const wordCloudConfig = this._wordCloudConfig ?? {};\n\n return {\n ...wordCloudConfig,\n ...this._getCommonTransformOptions(),\n // TIP: 非浏览器环境下,使用 fast 布局,否则会出现兼容问题\n layoutType: this._wordCloudConfig.layoutMode,\n\n rotate: this._rotateAngles,\n\n randomVisible: this._spec.random ?? DEFAULT_RANDOM,\n clip: this._wordCloudConfig.drawOutOfBound === 'clip',\n shrink: this._wordCloudConfig.zoomToFit.shrink,\n enlarge: this._wordCloudConfig.zoomToFit.enlarge,\n minFontSize: this._wordCloudConfig.zoomToFit.fontSizeLimitMin,\n progressiveTime: this._wordCloudConfig.progressiveTime,\n progressiveStep: this._wordCloudConfig.progressiveStep,\n repeatFill: this._wordCloudConfig.zoomToFit.repeat\n };\n }\n\n protected _wordCloudShapeTransformOption(): Object {\n const fillingWordStyleSpec = this._spec.fillingWord?.style ?? {};\n const wordCloudShapeConfig = this._wordCloudShapeConfig ?? {};\n\n return {\n ...wordCloudShapeConfig,\n ...this._getCommonTransformOptions(),\n measureCache: this._wordMeasureCache,\n\n rotateList: this._rotateAngles,\n fillingRotateList: wordCloudShapeConfig.fillingRotateAngles,\n\n fillingFontFamily: isValid(wordCloudShapeConfig.fillingFontFamilyField)\n ? { field: wordCloudShapeConfig.fillingFontFamilyField }\n : fillingWordStyleSpec.fontFamily ?? this._defaultFontFamily,\n fillingPadding: this._spec.fillingWord?.padding ?? DEFAULT_FONT_PADDING,\n fillingFontStyle: isValid(wordCloudShapeConfig.fillingFontStyleField)\n ? { field: wordCloudShapeConfig.fillingFontStyleField }\n : fillingWordStyleSpec.fontStyle,\n // 如果配置了字段映射,优先按照映射进行展示\n fillingFontWeight: isValid(wordCloudShapeConfig.fillingFontWeightField)\n ? {\n field: wordCloudShapeConfig.fillingFontWeightField\n }\n : fillingWordStyleSpec.fontWeight // 填充词fontWeight默认不跟随valueField\n };\n }\n\n getStatisticFields() {\n const fields: { key: string; operations: Array<'max' | 'min' | 'values'> }[] = [];\n fields.push({ key: this._nameField, operations: ['values'] });\n fields.push({ key: this._valueField, operations: ['max', 'min'] });\n return fields;\n }\n dataToPosition(data: Datum): IPoint {\n return null;\n }\n dataToPositionX(data: any): number {\n return null;\n }\n dataToPositionY(data: any): number {\n return null;\n }\n dataToPositionZ(data: any): number {\n return null;\n }\n valueToPosition(value1: any, value2?: any): IPoint {\n return null;\n }\n\n getGroupFields(): string[] {\n // do nothing\n return [];\n }\n\n getStackGroupFields(): string[] {\n // do nothing\n return [];\n }\n\n getStackValueField(): string {\n // do nothing\n return '';\n }\n\n onLayoutEnd(ctx: any): void {\n super.onLayoutEnd(ctx);\n this.compile();\n this._dataChange = false;\n }\n\n getActiveMarks(): IMark[] {\n return [this._wordMark];\n }\n\n reInit() {\n super.reInit();\n if (this._keyWordColorCallback) {\n this._keyWordColorCallback = null;\n }\n\n if (this._fillingColorCallback) {\n this._fillingColorCallback = null;\n }\n\n this._wordMeasureCache?.clear();\n }\n\n release() {\n super.release();\n this._wordMeasureCache?.clear();\n this._wordMeasureCache = undefined;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/series/word-cloud/base.ts"],"names":[],"mappings":";;;AAEA,6CAAkE;AAClE,6CAA2C;AAC3C,8CAAsG;AACtG,wDAA0D;AAG1D,wCAA+C;AAC/C,qCAWkB;AAQlB,iDAA6E;AAC7E,0DAA4D;AAE5D,qDAAiD;AACjD,yEAAoE;AACpE,yCAAiD;AAEjD,gDAA6C;AAE7C,6CAA+C;AAK/C,MAAa,mBAAmF,SAAQ,wBAAa;IAArH;;QAmBY,mBAAc,GAA+B,CAAC,8BAAqB,EAAE,8BAAqB,CAAC,CAAC;QAU5F,sBAAiB,GAAY,KAAK,CAAC;QAUnC,gBAAW,GAAY,IAAI,CAAC;QAE5B,2BAAsB,GAAG,CAAC,MAAyB,EAAE,QAAiB,EAAE,EAAE;YAClF,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAC5B,CAAC,CAAC;QAgNF,iBAAY,GAAG,CAAC,KAAY,EAAE,EAAE;YAC9B,IAAI,KAAK,CAAC,aAAa,EAAE;gBACvB,IAAI,CAAC,IAAI,CAAC,qBAAqB,IAAI,IAAI,CAAC,WAAW,EAAE;oBAEnD,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC,oBAAoB;wBAC1E,CAAC,CAAC,CAAC,KAAY,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,oBAAoB,CAAC;wBAC1E,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,EAAE,IAAI,CA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9B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;SACnC;IACH,CAAC;;AArdH,kDAsdC;AArdiB,wBAAI,GAAkB,8BAAmB,CAAC","file":"base.js","sourcesContent":["/* eslint-disable no-duplicate-imports */\nimport type { IPadding } from '@visactor/vutils';\nimport { isNil, isObject, isValidNumber } from '@visactor/vutils';\nimport { isValid } from '@visactor/vutils';\nimport { DEFAULT_DATA_INDEX, DEFAULT_DATA_KEY, DEFAULT_DATA_SERIES_FIELD } from '../../constant/data';\nimport { AttributeLevel } from '../../constant/attribute';\nimport type { SeriesMarkMap } from '../interface';\nimport { SeriesMarkNameEnum } from '../interface/type';\nimport { isTrueBrowser } from '../../util/env';\nimport {\n DEFAULT_DRAW_OUT_OF_BOUND,\n DEFAULT_FONTSIZE_RANGE,\n DEFAULT_FONT_PADDING,\n DEFAULT_FONT_WEIGHT_RANGE,\n DEFAULT_MASK_SHAPE,\n DEFAULT_MIN_FONT_SIZE,\n DEFAULT_RANDOM,\n DEFAULT_ROTATE_ANGLES,\n DEFAULT_ZOOM_TO_FIT,\n SHAPE_TYPE\n} from './config';\nimport type {\n IWordCloudSeriesSpec,\n WordCloudConfigType,\n WordCloudShapeConfigType,\n WordCloudShapeType\n} from './interface';\nimport type { Datum, IMarkSpec, IPoint, ITextMarkSpec } from '../../typings';\nimport { animationConfig, userAnimationConfig } from '../../animation/utils';\nimport { WORD_CLOUD_TEXT } from '../../constant/word-cloud';\nimport type { ICompilableMark } from '../../compile/mark';\nimport { BaseSeries } from '../base/base-series';\nimport { ColorOrdinalScale } from '../../scale/color-ordinal-scale';\nimport { wordCloudSeriesMark } from './constant';\nimport type { IStateAnimateSpec } from '../../animation/spec';\nimport { Factory } from '../../core/factory';\nimport type { IMark, IRectMark, ITextMark } from '../../mark/interface';\nimport { LinearScale } from '@visactor/vscale';\nimport type { GeometricMaskShape, TextShapeMask } from '@visactor/vgrammar-util';\n\nexport type IBaseWordCloudSeriesSpec = Omit<IWordCloudSeriesSpec, 'type'> & { type: string };\n\nexport class BaseWordCloudSeries<T extends IBaseWordCloudSeriesSpec = IBaseWordCloudSeriesSpec> extends BaseSeries<T> {\n static readonly mark: SeriesMarkMap = wordCloudSeriesMark;\n\n protected _nameField: string;\n protected _valueField?: string;\n setValueField(field: string) {\n if (isValid(field)) {\n this._valueField = field;\n }\n }\n\n protected _colorMode: 'linear' | 'ordinal';\n protected _colorList: string[];\n protected _rotateAngles?: number[];\n protected _fontWeightRange?: [number, number];\n protected _textField?: string;\n protected _maskCanvas?: HTMLCanvasElement;\n protected _maskMark?: IRectMark;\n\n protected _fontSizeRange?: [number, number] | 'auto' = [DEFAULT_MIN_FONT_SIZE, DEFAULT_MIN_FONT_SIZE];\n setFontSizeRange(fontSizeRange: [number, number] | 'auto') {\n if (isValid(fontSizeRange)) {\n this._fontSizeRange = fontSizeRange;\n } else {\n this._fontSizeRange = DEFAULT_FONTSIZE_RANGE;\n }\n }\n\n protected _maskShape?: string | WordCloudShapeType | TextShapeMask | GeometricMaskShape;\n protected _isWordCloudShape: boolean = false;\n\n protected _wordCloudConfig?: WordCloudConfigType;\n protected _wordCloudShapeConfig?: WordCloudShapeConfigType;\n\n protected _padding?: IPadding;\n protected _defaultFontFamily: string;\n\n protected _keyWordColorCallback: (datum: Datum) => string;\n protected _fillingColorCallback: (datum: Datum) => string;\n protected _dataChange: boolean = true;\n\n protected handleMaskCanvasUpdate = (canvas: HTMLCanvasElement, imageUrl?: string) => {\n this._maskCanvas = canvas;\n };\n /**\n * @override\n */\n setAttrFromSpec() {\n super.setAttrFromSpec();\n // series布局相关\n this._padding = this._option.getChart().padding;\n\n // 普通词云 & 形状词云 共有spec相关\n this._nameField = this._spec.nameField;\n this._colorMode = this._spec.colorMode ?? 'ordinal';\n this._colorList = this._spec.colorList;\n this.setValueField(this._spec.valueField);\n this._fontWeightRange = this._spec.fontWeightRange ?? DEFAULT_FONT_WEIGHT_RANGE;\n this._rotateAngles = this._spec.rotateAngles ?? DEFAULT_ROTATE_ANGLES;\n this.setFontSizeRange(this._spec.fontSizeRange);\n this._maskShape = this._spec.maskShape ?? DEFAULT_MASK_SHAPE;\n this._textField = this._spec.word?.formatMethod ? WORD_CLOUD_TEXT : this._nameField;\n const wordCloudConfig = this._spec.wordCloudConfig;\n // 普通词云spec相关\n this._wordCloudConfig = {\n drawOutOfBound: DEFAULT_DRAW_OUT_OF_BOUND,\n layoutMode: 'default',\n zoomToFit: DEFAULT_ZOOM_TO_FIT,\n ...this._spec.wordCloudConfig\n };\n\n if ((!wordCloudConfig || isNil(wordCloudConfig.layoutMode)) && !isTrueBrowser(this._option.mode)) {\n this._wordCloudConfig.layoutMode = 'fast';\n }\n\n // 形状词云spec相关\n this._wordCloudShapeConfig = {\n fillingSeriesField: this.getSeriesField(),\n fillingRotateAngles: DEFAULT_ROTATE_ANGLES,\n layoutMode: 'default',\n ...this._spec.wordCloudShapeConfig\n };\n\n this._isWordCloudShape =\n !SHAPE_TYPE.includes(this._maskShape as string) &&\n !['fast', 'grid', 'cloud'].includes(this._wordCloudConfig.layoutMode);\n this._defaultFontFamily = this._option.getTheme().fontFamily as string;\n }\n\n /**\n * @override\n */\n protected initData(): void {\n super.initData();\n // data改变时, 需要重新编译, 重新布局\n this.getViewData()?.target?.addListener('change', () => {\n this._dataChange = true;\n this.compile();\n });\n }\n\n protected _wordMark: ITextMark;\n\n initMark(): void {\n if (this._spec.wordMask?.visible) {\n this._maskMark = this._createMark(BaseWordCloudSeries.mark.wordMask, { dataView: false }) as IRectMark;\n }\n\n this._wordMark = this._createMark(\n BaseWordCloudSeries.mark.word,\n {\n key: DEFAULT_DATA_KEY,\n groupKey: this._seriesField,\n isSeriesMark: true\n },\n {\n morphElementKey: this._seriesField\n }\n ) as ITextMark;\n }\n\n initMarkStyle() {\n this.initMarkStyleOfWord(this._wordMark, this._spec.word, this._spec.colorHexField, this._seriesField);\n\n if (this._maskMark) {\n this.setMarkStyle(\n this._maskMark,\n {\n width: () => {\n return this._region.getLayoutRect().width;\n },\n height: () => {\n return this._region.getLayoutRect().height;\n },\n background: () => {\n return this._maskCanvas;\n }\n },\n 'normal',\n AttributeLevel.Series\n );\n }\n }\n\n initMarkStyleOfWord(\n wordMark: ITextMark,\n wordSpec?: IMarkSpec<ITextMarkSpec>,\n colorHexField?: string,\n seriesField?: string,\n isFillingWord?: boolean\n ): void {\n if (!wordMark) {\n return;\n }\n this.setMarkStyle(\n wordMark,\n {\n text: (wordSpec as any)?.formatMethod\n ? (datum: Datum) => {\n return (wordSpec as any).formatMethod(datum);\n }\n : (datum: Datum) => datum[this._textField],\n x: (datum: Datum) => datum.x,\n y: (datum: Datum) => datum.y,\n fontSize: (datum: Datum) => datum.fontSize,\n fontStyle: (datum: Datum) => datum.fontStyle,\n\n angle: (datum: Datum) => datum.angle,\n visible: (datum: Datum) => datum.visible\n },\n 'normal',\n AttributeLevel.Series\n );\n this.setMarkStyle(\n wordMark,\n {\n fill: wordSpec?.style?.fill ?? this.getWordColor,\n // style和field相关的配置都已经传给vgrammar, 所以这里直接拿结果就可以\n fontWeight: (datum: Datum) => datum.fontWeight,\n fontFamily: (datum: Datum) => datum.fontFamily\n },\n 'normal',\n AttributeLevel.User_Mark\n );\n }\n\n protected initTooltip() {\n super.initTooltip();\n\n this._wordMark && this._tooltipHelper.activeTriggerSet.mark.add(this._wordMark);\n }\n\n initAnimation() {\n [this._wordMark].forEach(mark => {\n if (mark) {\n const appearPreset = (this._spec?.animationAppear as IStateAnimateSpec<any>)?.preset;\n const params = {\n animationConfig: () => mark.getAnimationConfig()?.appear?.[0]\n };\n mark.setAnimationConfig(\n animationConfig(\n Factory.getAnimationInKey('wordCloud')(params, appearPreset),\n userAnimationConfig(SeriesMarkNameEnum.word, this._spec, this._markAttributeContext)\n )\n );\n }\n });\n }\n\n protected getWordOrdinalColorScale(field: string, isFillingWord: boolean) {\n const colorList = isFillingWord ? this._wordCloudShapeConfig.fillingColorList : this._colorList;\n const colorDomain = field ? this.getViewData()?.latestData.map((datum: Datum) => datum[field]) : [];\n const colorRange = colorList ?? this._option.globalScale.getScale('color')?.range() ?? this._getDataScheme();\n return new ColorOrdinalScale().domain(colorDomain).range?.(colorRange);\n }\n\n protected initColorCallback(field: string, isFillingWord: boolean) {\n if (this._colorMode === 'ordinal') {\n const scale = this.getWordOrdinalColorScale(field, isFillingWord);\n return (datum: Datum) => {\n return scale.scale(datum[field ?? DEFAULT_DATA_SERIES_FIELD]);\n };\n }\n\n const colorList =\n (isFillingWord ? this._colorList : this._wordCloudShapeConfig.fillingColorList) ??\n this._option.globalScale.getScale('color').range();\n\n if (colorList.length === 1) {\n return (datum: Datum) => colorList[0];\n }\n\n if (this._valueField) {\n const stats = this.getRawDataStatisticsByField(this._valueField, true);\n if (stats.min === stats.max) {\n return colorList[0];\n }\n const scale = new LinearScale().domain([stats.min, stats.max]).range(colorList);\n\n return (datum: Datum) => {\n return scale.scale(datum[this._valueField]);\n };\n }\n\n const scale = new LinearScale().domain([0, this.getViewData()?.latestData?.length ?? 1]).range(colorList);\n\n return (datum: Datum) => {\n return scale.scale(datum[DEFAULT_DATA_INDEX]);\n };\n }\n\n getWordColor = (datum: Datum) => {\n if (datum.isFillingWord) {\n if (!this._fillingColorCallback || this._dataChange) {\n // 如果updateData数据变更了, 颜色映射也需要重新计算\n this._fillingColorCallback = this._wordCloudShapeConfig.fillingColorHexField\n ? (datum: Datum) => datum[this._wordCloudShapeConfig.fillingColorHexField]\n : this.initColorCallback(this._wordCloudShapeConfig.fillingSeriesField, true);\n }\n\n return this._fillingColorCallback(datum);\n }\n\n if (!this._keyWordColorCallback || this._dataChange) {\n // 如果updateData数据变更了, 颜色映射也需要重新计算\n this._keyWordColorCallback = this._spec.colorHexField\n ? datum => datum[this._spec.colorHexField]\n : this.initColorCallback(this._seriesField, false);\n }\n\n return this._keyWordColorCallback(datum);\n };\n\n private _calculateFontWeight = (datum: Datum) => {\n const stats = this.getRawDataStatisticsByField(this._valueField, true);\n\n if (stats.min === stats.max) {\n return this._fontWeightRange[0];\n }\n\n return (\n this._fontWeightRange[0] +\n ((this._fontWeightRange[this._fontWeightRange.length - 1] - this._fontWeightRange[0]) *\n (datum[this._valueField] - stats.min)) /\n (stats.max - stats.min)\n );\n };\n\n compile(): void {\n super.compile();\n const { width, height } = this._region.getLayoutRect();\n // 非正常尺寸下不进行布局\n if (!isValidNumber(width) || !isValidNumber(height) || !(height > 0 && width > 0)) {\n return;\n }\n\n const product = (this._wordMark as ICompilableMark).getProduct();\n\n if (product) {\n const wordCloudTransforms: any[] = [];\n\n // 词云 transform\n if (!this._isWordCloudShape) {\n wordCloudTransforms.push({\n type: 'wordcloud',\n ...this._wordCloudTransformOption()\n });\n }\n // 形状词云 transform\n else {\n wordCloudTransforms.push({\n type: 'wordcloudShape',\n // 形状词云中必须要传入dataIndexKey, 否则填充词无法绘制\n ...this._wordCloudShapeTransformOption()\n });\n }\n\n // 挂到mark的transform上\n product.transform(wordCloudTransforms);\n }\n }\n\n protected _getCommonTransformOptions(): any {\n const { width, height } = this._region.getLayoutRect();\n const wordSpec = this._spec.word ?? {};\n const wordStyleSpec = wordSpec.style ?? {};\n\n return {\n size: [width, height],\n shape:\n isObject(this._maskShape) &&\n (this._maskShape as TextShapeMask).type === 'text' &&\n isNil((this._maskShape as TextShapeMask).fontFamily)\n ? {\n fontFamily: this._option.getTheme()?.fontFamily,\n ...this._maskShape\n }\n : this._maskShape,\n onUpdateMaskCanvas: this.handleMaskCanvasUpdate,\n dataIndexKey: DEFAULT_DATA_KEY,\n text: wordSpec.formatMethod\n ? (datum: Datum) => {\n return wordSpec.formatMethod(datum);\n }\n : { field: this._textField },\n fontSize: this._valueField ? { field: this._valueField } : this._fontSizeRange[0],\n fontSizeRange: this._fontSizeRange === 'auto' ? null : this._fontSizeRange,\n\n padding: this._spec.word?.padding ?? DEFAULT_FONT_PADDING,\n fontFamily: isValid(this._spec.fontFamilyField)\n ? { field: this._spec.fontFamilyField }\n : wordStyleSpec.fontFamily ?? this._defaultFontFamily,\n // 为了保持和旧版逻辑一致,优先级如下: spec field > mark style > default (根据valueField映射)\n fontWeight: isValid(this._spec.fontWeightField)\n ? { field: this._spec.fontWeightField }\n : isValid(wordStyleSpec.fontWeight)\n ? wordStyleSpec.fontWeight\n : isValid(this._valueField)\n ? this._calculateFontWeight\n : 'normal',\n fontStyle: isValid(this._spec.fontStyleField) ? { field: this._spec.fontStyleField } : wordStyleSpec.fontStyle\n };\n }\n\n protected _wordCloudTransformOption(): Object {\n const wordCloudConfig = this._wordCloudConfig ?? {};\n\n return {\n ...wordCloudConfig,\n ...this._getCommonTransformOptions(),\n // TIP: 非浏览器环境下,使用 fast 布局,否则会出现兼容问题\n layoutType: this._wordCloudConfig.layoutMode,\n\n rotate: this._rotateAngles,\n\n randomVisible: this._spec.random ?? DEFAULT_RANDOM,\n clip: this._wordCloudConfig.drawOutOfBound === 'clip',\n shrink: this._wordCloudConfig.zoomToFit.shrink,\n enlarge: this._wordCloudConfig.zoomToFit.enlarge,\n minFontSize: this._wordCloudConfig.zoomToFit.fontSizeLimitMin,\n progressiveTime: this._wordCloudConfig.progressiveTime,\n progressiveStep: this._wordCloudConfig.progressiveStep,\n repeatFill: this._wordCloudConfig.zoomToFit.repeat\n };\n }\n\n protected _wordCloudShapeTransformOption(): Object {\n const fillingWordStyleSpec = this._spec.fillingWord?.style ?? {};\n const wordCloudShapeConfig = this._wordCloudShapeConfig ?? {};\n\n return {\n ...wordCloudShapeConfig,\n ...this._getCommonTransformOptions(),\n\n rotateList: this._rotateAngles,\n fillingRotateList: wordCloudShapeConfig.fillingRotateAngles,\n\n fillingFontFamily: isValid(wordCloudShapeConfig.fillingFontFamilyField)\n ? { field: wordCloudShapeConfig.fillingFontFamilyField }\n : fillingWordStyleSpec.fontFamily ?? this._defaultFontFamily,\n fillingPadding: this._spec.fillingWord?.padding ?? DEFAULT_FONT_PADDING,\n fillingFontStyle: isValid(wordCloudShapeConfig.fillingFontStyleField)\n ? { field: wordCloudShapeConfig.fillingFontStyleField }\n : fillingWordStyleSpec.fontStyle,\n // 如果配置了字段映射,优先按照映射进行展示\n fillingFontWeight: isValid(wordCloudShapeConfig.fillingFontWeightField)\n ? {\n field: wordCloudShapeConfig.fillingFontWeightField\n }\n : fillingWordStyleSpec.fontWeight // 填充词fontWeight默认不跟随valueField\n };\n }\n\n getStatisticFields() {\n const fields: { key: string; operations: Array<'max' | 'min' | 'values'> }[] = [];\n fields.push({ key: this._nameField, operations: ['values'] });\n fields.push({ key: this._valueField, operations: ['max', 'min'] });\n return fields;\n }\n dataToPosition(data: Datum): IPoint {\n return null;\n }\n dataToPositionX(data: any): number {\n return null;\n }\n dataToPositionY(data: any): number {\n return null;\n }\n dataToPositionZ(data: any): number {\n return null;\n }\n valueToPosition(value1: any, value2?: any): IPoint {\n return null;\n }\n\n getGroupFields(): string[] {\n // do nothing\n return [];\n }\n\n getStackGroupFields(): string[] {\n // do nothing\n return [];\n }\n\n getStackValueField(): string {\n // do nothing\n return '';\n }\n\n onLayoutEnd(ctx: any): void {\n super.onLayoutEnd(ctx);\n this.compile();\n this._dataChange = false;\n }\n\n getActiveMarks(): IMark[] {\n return [this._wordMark];\n }\n\n reInit() {\n super.reInit();\n if (this._keyWordColorCallback) {\n this._keyWordColorCallback = null;\n }\n\n if (this._fillingColorCallback) {\n this._fillingColorCallback = null;\n }\n }\n}\n"]}
@@ -64,35 +64,38 @@ export class Title extends BaseComponent {
64
64
  };
65
65
  }
66
66
  _getTitleAttrs() {
67
- var _a, _b, _c, _d, _e, _f, _g, _h;
67
+ var _a, _b, _c, _d, _e, _f;
68
68
  if (!1 === this._spec.visible) return {
69
69
  visible: !1
70
70
  };
71
- const layoutRect = this.getLayoutRect(), titleWidth = calcLayoutNumber(this._spec.width, layoutRect.width, null, layoutRect.width), titleMaxWidth = calcLayoutNumber(this._spec.maxWidth, layoutRect.width, null, layoutRect.width), maxWidth = Math.max(Math.min(titleWidth, titleMaxWidth, layoutRect.width), 0), attrs = Object.assign(Object.assign({}, pickWithout(this._spec, [ "padding" ])), {
71
+ const layoutRect = this.getLayoutRect(), titleWidth = calcLayoutNumber(this._spec.width, layoutRect.width, null, layoutRect.width), titleMaxWidth = calcLayoutNumber(this._spec.maxWidth, layoutRect.width, null, layoutRect.width), maxWidth = Math.max(Math.min(titleWidth, titleMaxWidth, layoutRect.width), 0), hasText = isValid(this._spec.text) && "" !== this._spec.text, hasSubtext = isValid(this._spec.subtext) && "" !== this._spec.subtext, attrs = Object.assign(Object.assign({}, pickWithout(this._spec, [ "padding" ])), {
72
72
  textType: null !== (_a = this._spec.textType) && void 0 !== _a ? _a : "text",
73
- text: null !== (_b = this._spec.text) && void 0 !== _b ? _b : "",
74
- subtextType: null !== (_c = this._spec.subtextType) && void 0 !== _c ? _c : "text",
75
- subtext: null !== (_d = this._spec.subtext) && void 0 !== _d ? _d : "",
76
- x: null !== (_e = this._spec.x) && void 0 !== _e ? _e : 0,
77
- y: null !== (_f = this._spec.y) && void 0 !== _f ? _f : 0,
73
+ text: hasText ? this._spec.text : void 0,
74
+ subtextType: null !== (_b = this._spec.subtextType) && void 0 !== _b ? _b : "text",
75
+ subtext: hasSubtext ? this._spec.subtext : void 0,
76
+ x: null !== (_c = this._spec.x) && void 0 !== _c ? _c : 0,
77
+ y: null !== (_d = this._spec.y) && void 0 !== _d ? _d : 0,
78
78
  height: this._spec.height,
79
79
  minWidth: this._spec.minWidth,
80
80
  maxWidth: maxWidth,
81
81
  minHeight: this._spec.minHeight,
82
82
  maxHeight: this._spec.maxHeight,
83
83
  padding: this._spec.innerPadding,
84
- align: null !== (_g = this._spec.align) && void 0 !== _g ? _g : "left",
85
- verticalAlign: null !== (_h = this._spec.verticalAlign) && void 0 !== _h ? _h : "top",
84
+ align: null !== (_e = this._spec.align) && void 0 !== _e ? _e : "left",
85
+ verticalAlign: null !== (_f = this._spec.verticalAlign) && void 0 !== _f ? _f : "top",
86
86
  textStyle: Object.assign({
87
- width: maxWidth,
88
87
  maxLineWidth: maxWidth
89
88
  }, this._spec.textStyle),
90
89
  subtextStyle: Object.assign({
91
90
  maxLineWidth: maxWidth
92
91
  }, this._spec.subtextStyle)
93
92
  });
94
- return isValid(this._spec.width) && (attrs.textStyle.width = Math.max(titleWidth, layoutRect.width),
95
- attrs.subtextStyle.width = attrs.textStyle.width), attrs;
93
+ if (hasText && (attrs.textStyle.width = maxWidth), hasSubtext && (attrs.subtextStyle.width = maxWidth),
94
+ isValid(this._spec.width)) {
95
+ const clampedWidth = Math.max(Math.min(titleWidth, layoutRect.width), 0);
96
+ hasText ? attrs.textStyle.width = clampedWidth : delete attrs.textStyle.width, hasSubtext && (attrs.subtextStyle.width = clampedWidth);
97
+ }
98
+ return attrs;
96
99
  }
97
100
  _createOrUpdateTitleComponent(attrs) {
98
101
  if (this._titleComponent) isEqual(attrs, this._cacheAttrs) || this._titleComponent.setAttributes(attrs); else {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/title/title.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAI7C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,KAAK,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAMxE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,OAAO,KAAyC,SAAQ,aAAgB;IAe5E,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,YAAY,IAAO,EAAE,OAAyB;QAC5C,KAAK,CAAC,IAAI,EAAE,OAA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../../constant/layout';\nimport { Factory } from '../../core/factory';\nimport type { IModelSpecInfo } from '../../model/interface';\nimport type { IRegion } from '../../region/interface';\nimport type { IPoint, IOrientType, ILayoutType, ILayoutRect } from '../../typings';\nimport { calcLayoutNumber, isValidOrient } from '../../util/space';\nimport { BaseComponent } from '../base/base-component';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IComponentOption } from '../interface';\nimport { ComponentTypeEnum } from '../interface/type';\nimport type { ITitle, ITitleSpec } from './interface';\nimport { Title as TitleComponents } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport type { TitleAttrs } from '@visactor/vrender-components';\nimport type { IGraphic, IGroup, INode } from '@visactor/vrender-core';\nimport type { Maybe } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { isEqual, isValidNumber, pickWithout, isValid } from '@visactor/vutils';\nimport { getSpecInfo } from '../util';\n\nexport class Title<T extends ITitleSpec = ITitleSpec> extends BaseComponent<T> implements ITitle {\n static type = ComponentTypeEnum.title;\n type = ComponentTypeEnum.title;\n static specKey = ComponentTypeEnum.title;\n specKey: string = ComponentTypeEnum.title;\n\n layoutType: ILayoutType = 'normal';\n layoutZIndex: number = LayoutZIndex.Title;\n layoutLevel: number = LayoutLevel.Title;\n\n protected _orient: IOrientType = 'top';\n\n private _titleComponent: TitleComponents;\n private _cacheAttrs: TitleAttrs;\n\n get orient() {\n return this._orient;\n }\n\n constructor(spec: T, options: IComponentOption) {\n super(spec, options);\n this._orient = isValidOrient(spec.orient) ? spec.orient : 'top';\n }\n\n initLayout(): void {\n super.initLayout();\n this._layout && (this._layout.layoutOrient = this._orient);\n }\n\n static getSpecInfo(chartSpec: any): Maybe<IModelSpecInfo[]> {\n return getSpecInfo<ITitleSpec>(chartSpec, this.specKey, ComponentTypeEnum.title, (s: ITitleSpec) => {\n return s.visible !== false;\n });\n }\n\n onRender(ctx: any): void {\n // do nothing\n }\n\n /**\n * updateSpec\n */\n _compareSpec(spec: T, prevSpec: T) {\n const result = super._compareSpec(spec, prevSpec);\n\n if (prevSpec?.orient !== spec?.orient || (prevSpec as any)?.visible !== (spec as any).visible) {\n // title 组件切换visible会影响布局,所以需要重新remake\n result.reMake = true;\n }\n\n result.change = true;\n result.reRender = true;\n return result;\n }\n\n // region\n changeRegions(regions: IRegion[]): void {\n // do nothing\n }\n\n update(ctx: IComponentOption) {\n // TODO\n }\n\n resize(ctx: IComponentOption) {\n // TODO\n }\n\n afterSetLayoutStartPoint(pos: IPoint): void {\n if (isValidNumber(pos.x)) {\n this._titleComponent && this._titleComponent.setAttribute('x', pos.x);\n }\n if (isValidNumber(pos.y)) {\n this._titleComponent && this._titleComponent.setAttribute('y', pos.y);\n }\n super.afterSetLayoutStartPoint(pos);\n }\n\n getBoundsInRect(rect: ILayoutRect) {\n let result: Partial<ILayoutRect> = {};\n this.setLayoutRect(rect);\n\n const attrs = this._getTitleAttrs();\n this._createOrUpdateTitleComponent(attrs);\n\n result = this._getTitleLayoutRect();\n const { x, y } = this.getLayoutStartPoint();\n return {\n x1: x,\n y1: y,\n x2: x + result.width,\n y2: y + result.height\n };\n }\n\n private _getTitleLayoutRect() {\n const titleBounds = this._titleComponent.AABBBounds;\n const width = this._spec.width ? this._spec.width : isValidNumber(titleBounds.width()) ? titleBounds.width() : 0;\n const height = this._spec.height\n ? this._spec.height\n : isValidNumber(titleBounds.height())\n ? titleBounds.height()\n : 0;\n return {\n width,\n height\n };\n }\n\n private _getTitleAttrs() {\n // 当 width 小于 0 时,设置为 0,负数场景容易引起不可预知的问题\n if (this._spec.visible === false) {\n return { visible: false };\n }\n const layoutRect = this.getLayoutRect();\n const titleWidth = calcLayoutNumber(this._spec.width, layoutRect.width, null, layoutRect.width);\n const titleMaxWidth = calcLayoutNumber(this._spec.maxWidth, layoutRect.width, null, layoutRect.width);\n const maxWidth = Math.max(Math.min(titleWidth, titleMaxWidth, layoutRect.width), 0);\n\n const attrs = {\n ...(pickWithout(this._spec, ['padding']) as any),\n textType: this._spec.textType ?? 'text',\n text: this._spec.text ?? '',\n subtextType: this._spec.subtextType ?? 'text',\n subtext: this._spec.subtext ?? '',\n x: this._spec.x ?? 0,\n y: this._spec.y ?? 0,\n height: this._spec.height,\n minWidth: this._spec.minWidth,\n maxWidth,\n minHeight: this._spec.minHeight,\n maxHeight: this._spec.maxHeight,\n padding: this._spec.innerPadding,\n align: this._spec.align ?? 'left',\n verticalAlign: this._spec.verticalAlign ?? 'top',\n textStyle: {\n width: maxWidth,\n maxLineWidth: maxWidth,\n ...this._spec.textStyle\n },\n subtextStyle: {\n maxLineWidth: maxWidth,\n ...this._spec.subtextStyle\n }\n } as TitleAttrs;\n\n if (isValid(this._spec.width)) {\n attrs.textStyle.width = Math.max(titleWidth, layoutRect.width);\n attrs.subtextStyle.width = attrs.textStyle.width;\n }\n return attrs;\n }\n\n private _createOrUpdateTitleComponent(attrs: TitleAttrs): TitleComponents {\n if (this._titleComponent) {\n if (!isEqual(attrs, this._cacheAttrs)) {\n this._titleComponent.setAttributes(attrs);\n }\n } else {\n const container = this.getContainer();\n const title = new TitleComponents(attrs);\n title.name = 'title';\n container.add(title as unknown as INode);\n this._titleComponent = title;\n // 代理 title 组件上的事件\n title.on('*', (event: any, type: string) => this._delegateEvent(title as unknown as IGraphic, event, type));\n }\n this._cacheAttrs = attrs;\n return this._titleComponent;\n }\n\n protected _getNeedClearVRenderComponents(): IGraphic[] {\n return [this._titleComponent] as unknown as IGroup[];\n }\n\n clear(): void {\n super.clear();\n this._cacheAttrs = null;\n }\n}\n\nexport const registerTitle = () => {\n Factory.registerComponent(Title.type, Title);\n};\n"]}
1
+ {"version":3,"sources":["../src/component/title/title.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAI7C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,E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I,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE;gBACrC,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;aAC3C;SACF;aAAM;YACL,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YACtC,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;YACzC,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC;YACrB,SAAS,CAAC,GAAG,CAAC,KAAyB,CAAC,CAAC;YACzC,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;YAE7B,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,KAAU,EAAE,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,KAA4B,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;SAC7G;QACD,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAES,8BAA8B;QACtC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAwB,CAAC;IACvD,CAAC;IAED,KAAK;QACH,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;;AArMM,UAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC;AAE/B,aAAO,GAAG,iBAAiB,CAAC,KAAK,CAAC;AAsM3C,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC,CAAC","file":"title.js","sourcesContent":["import { LayoutLevel, LayoutZIndex } from '../../constant/layout';\nimport { Factory } from '../../core/factory';\nimport type { IModelSpecInfo } from '../../model/interface';\nimport type { IRegion } from '../../region/interface';\nimport type { IPoint, IOrientType, ILayoutType, ILayoutRect } from '../../typings';\nimport { calcLayoutNumber, isValidOrient } from '../../util/space';\nimport { BaseComponent } from '../base/base-component';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IComponentOption } from '../interface';\nimport { ComponentTypeEnum } from '../interface/type';\nimport type { ITitle, ITitleSpec } from './interface';\nimport { Title as TitleComponents } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport type { TitleAttrs } from '@visactor/vrender-components';\nimport type { IGraphic, IGroup, INode } from '@visactor/vrender-core';\nimport type { Maybe } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { isEqual, isValidNumber, pickWithout, isValid } from '@visactor/vutils';\nimport { getSpecInfo } from '../util';\n\nexport class Title<T extends ITitleSpec = ITitleSpec> extends BaseComponent<T> implements ITitle {\n static type = ComponentTypeEnum.title;\n type = ComponentTypeEnum.title;\n static specKey = ComponentTypeEnum.title;\n specKey: string = ComponentTypeEnum.title;\n\n layoutType: ILayoutType = 'normal';\n layoutZIndex: number = LayoutZIndex.Title;\n layoutLevel: number = LayoutLevel.Title;\n\n protected _orient: IOrientType = 'top';\n\n private _titleComponent: TitleComponents;\n private _cacheAttrs: TitleAttrs;\n\n get orient() {\n return this._orient;\n }\n\n constructor(spec: T, options: IComponentOption) {\n super(spec, options);\n this._orient = isValidOrient(spec.orient) ? spec.orient : 'top';\n }\n\n initLayout(): void {\n super.initLayout();\n this._layout && (this._layout.layoutOrient = this._orient);\n }\n\n static getSpecInfo(chartSpec: any): Maybe<IModelSpecInfo[]> {\n return getSpecInfo<ITitleSpec>(chartSpec, this.specKey, ComponentTypeEnum.title, (s: ITitleSpec) => {\n return s.visible !== false;\n });\n }\n\n onRender(ctx: any): void {\n // do nothing\n }\n\n /**\n * updateSpec\n */\n _compareSpec(spec: T, prevSpec: T) {\n const result = super._compareSpec(spec, prevSpec);\n\n if (prevSpec?.orient !== spec?.orient || (prevSpec as any)?.visible !== (spec as any).visible) {\n // title 组件切换visible会影响布局,所以需要重新remake\n result.reMake = true;\n }\n\n result.change = true;\n result.reRender = true;\n return result;\n }\n\n // region\n changeRegions(regions: IRegion[]): void {\n // do nothing\n }\n\n update(ctx: IComponentOption) {\n // TODO\n }\n\n resize(ctx: IComponentOption) {\n // TODO\n }\n\n afterSetLayoutStartPoint(pos: IPoint): void {\n if (isValidNumber(pos.x)) {\n this._titleComponent && this._titleComponent.setAttribute('x', pos.x);\n }\n if (isValidNumber(pos.y)) {\n this._titleComponent && this._titleComponent.setAttribute('y', pos.y);\n }\n super.afterSetLayoutStartPoint(pos);\n }\n\n getBoundsInRect(rect: ILayoutRect) {\n let result: Partial<ILayoutRect> = {};\n this.setLayoutRect(rect);\n\n const attrs = this._getTitleAttrs();\n this._createOrUpdateTitleComponent(attrs);\n\n result = this._getTitleLayoutRect();\n const { x, y } = this.getLayoutStartPoint();\n return {\n x1: x,\n y1: y,\n x2: x + result.width,\n y2: y + result.height\n };\n }\n\n private _getTitleLayoutRect() {\n const titleBounds = this._titleComponent.AABBBounds;\n const width = this._spec.width ? this._spec.width : isValidNumber(titleBounds.width()) ? titleBounds.width() : 0;\n const height = this._spec.height\n ? this._spec.height\n : isValidNumber(titleBounds.height())\n ? titleBounds.height()\n : 0;\n return {\n width,\n height\n };\n }\n\n private _getTitleAttrs() {\n /**\n * 生成标题组件的渲染属性,统一计算宽高与对齐参数,\n * 并在仅副标题场景下避免主标题宽度影响副标题布局。\n */\n if (this._spec.visible === false) {\n return { visible: false };\n }\n const layoutRect = this.getLayoutRect();\n const titleWidth = calcLayoutNumber(this._spec.width, layoutRect.width, null, layoutRect.width);\n const titleMaxWidth = calcLayoutNumber(this._spec.maxWidth, layoutRect.width, null, layoutRect.width);\n const maxWidth = Math.max(Math.min(titleWidth, titleMaxWidth, layoutRect.width), 0);\n const hasText = isValid(this._spec.text) && this._spec.text !== '';\n const hasSubtext = isValid(this._spec.subtext) && this._spec.subtext !== '';\n\n const attrs = {\n ...(pickWithout(this._spec, ['padding']) as any),\n textType: this._spec.textType ?? 'text',\n text: hasText ? this._spec.text : undefined,\n subtextType: this._spec.subtextType ?? 'text',\n subtext: hasSubtext ? this._spec.subtext : undefined,\n x: this._spec.x ?? 0,\n y: this._spec.y ?? 0,\n height: this._spec.height,\n minWidth: this._spec.minWidth,\n maxWidth,\n minHeight: this._spec.minHeight,\n maxHeight: this._spec.maxHeight,\n padding: this._spec.innerPadding,\n align: this._spec.align ?? 'left',\n verticalAlign: this._spec.verticalAlign ?? 'top',\n textStyle: {\n maxLineWidth: maxWidth,\n ...this._spec.textStyle\n },\n subtextStyle: {\n maxLineWidth: maxWidth,\n ...this._spec.subtextStyle\n }\n } as TitleAttrs;\n\n // 仅在对应文本存在时设置 width,避免空主标题影响副标题的对齐与宽度计算\n if (hasText) {\n (attrs.textStyle as any).width = maxWidth;\n }\n if (hasSubtext) {\n (attrs.subtextStyle as any).width = maxWidth;\n }\n\n if (isValid(this._spec.width)) {\n const clampedWidth = Math.max(Math.min(titleWidth, layoutRect.width), 0);\n if (hasText) {\n (attrs.textStyle as any).width = clampedWidth;\n } else {\n // 主标题不存在时,不设置其 width\n delete (attrs.textStyle as any).width;\n }\n if (hasSubtext) {\n (attrs.subtextStyle as any).width = clampedWidth;\n }\n }\n return attrs;\n }\n\n private _createOrUpdateTitleComponent(attrs: TitleAttrs): TitleComponents {\n if (this._titleComponent) {\n if (!isEqual(attrs, this._cacheAttrs)) {\n this._titleComponent.setAttributes(attrs);\n }\n } else {\n const container = this.getContainer();\n const title = new TitleComponents(attrs);\n title.name = 'title';\n container.add(title as unknown as INode);\n this._titleComponent = title;\n // 代理 title 组件上的事件\n title.on('*', (event: any, type: string) => this._delegateEvent(title as unknown as IGraphic, event, type));\n }\n this._cacheAttrs = attrs;\n return this._titleComponent;\n }\n\n protected _getNeedClearVRenderComponents(): IGraphic[] {\n return [this._titleComponent] as unknown as IGroup[];\n }\n\n clear(): void {\n super.clear();\n this._cacheAttrs = null;\n }\n}\n\nexport const registerTitle = () => {\n Factory.registerComponent(Title.type, Title);\n};\n"]}
@@ -26,7 +26,6 @@ export declare class BaseWordCloudSeries<T extends IBaseWordCloudSeriesSpec = IB
26
26
  protected _isWordCloudShape: boolean;
27
27
  protected _wordCloudConfig?: WordCloudConfigType;
28
28
  protected _wordCloudShapeConfig?: WordCloudShapeConfigType;
29
- private _wordMeasureCache?;
30
29
  protected _padding?: IPadding;
31
30
  protected _defaultFontFamily: string;
32
31
  protected _keyWordColorCallback: (datum: Datum) => string;
@@ -64,5 +63,4 @@ export declare class BaseWordCloudSeries<T extends IBaseWordCloudSeriesSpec = IB
64
63
  onLayoutEnd(ctx: any): void;
65
64
  getActiveMarks(): IMark[];
66
65
  reInit(): void;
67
- release(): void;
68
66
  }
@@ -10,8 +10,6 @@ import { isTrueBrowser } from "../../util/env";
10
10
 
11
11
  import { DEFAULT_DRAW_OUT_OF_BOUND, DEFAULT_FONTSIZE_RANGE, DEFAULT_FONT_PADDING, DEFAULT_FONT_WEIGHT_RANGE, DEFAULT_MASK_SHAPE, DEFAULT_MIN_FONT_SIZE, DEFAULT_RANDOM, DEFAULT_ROTATE_ANGLES, DEFAULT_ZOOM_TO_FIT, SHAPE_TYPE } from "./config";
12
12
 
13
- import { WordMeasureCache } from "./measure-cache";
14
-
15
13
  import { animationConfig, userAnimationConfig } from "../../animation/utils";
16
14
 
17
15
  import { WORD_CLOUD_TEXT } from "../../constant/word-cloud";
@@ -64,14 +62,12 @@ export class BaseWordCloudSeries extends BaseSeries {
64
62
  fillingRotateAngles: DEFAULT_ROTATE_ANGLES,
65
63
  layoutMode: "default"
66
64
  }, this._spec.wordCloudShapeConfig), this._isWordCloudShape = !SHAPE_TYPE.includes(this._maskShape) && ![ "fast", "grid", "cloud" ].includes(this._wordCloudConfig.layoutMode),
67
- this._defaultFontFamily = this._option.getTheme().fontFamily, this._wordMeasureCache || (this._wordMeasureCache = new WordMeasureCache(1e3));
65
+ this._defaultFontFamily = this._option.getTheme().fontFamily;
68
66
  }
69
67
  initData() {
70
68
  var _a, _b;
71
69
  super.initData(), null === (_b = null === (_a = this.getViewData()) || void 0 === _a ? void 0 : _a.target) || void 0 === _b || _b.addListener("change", (() => {
72
- var _a;
73
- null === (_a = this._wordMeasureCache) || void 0 === _a || _a.clear(), this._dataChange = !0,
74
- this.compile();
70
+ this._dataChange = !0, this.compile();
75
71
  }));
76
72
  }
77
73
  initMark() {
@@ -212,7 +208,6 @@ export class BaseWordCloudSeries extends BaseSeries {
212
208
  var _a, _b, _c, _d, _e, _f;
213
209
  const fillingWordStyleSpec = null !== (_b = null === (_a = this._spec.fillingWord) || void 0 === _a ? void 0 : _a.style) && void 0 !== _b ? _b : {}, wordCloudShapeConfig = null !== (_c = this._wordCloudShapeConfig) && void 0 !== _c ? _c : {};
214
210
  return Object.assign(Object.assign(Object.assign({}, wordCloudShapeConfig), this._getCommonTransformOptions()), {
215
- measureCache: this._wordMeasureCache,
216
211
  rotateList: this._rotateAngles,
217
212
  fillingRotateList: wordCloudShapeConfig.fillingRotateAngles,
218
213
  fillingFontFamily: isValid(wordCloudShapeConfig.fillingFontFamilyField) ? {
@@ -268,14 +263,8 @@ export class BaseWordCloudSeries extends BaseSeries {
268
263
  return [ this._wordMark ];
269
264
  }
270
265
  reInit() {
271
- var _a;
272
266
  super.reInit(), this._keyWordColorCallback && (this._keyWordColorCallback = null),
273
- this._fillingColorCallback && (this._fillingColorCallback = null), null === (_a = this._wordMeasureCache) || void 0 === _a || _a.clear();
274
- }
275
- release() {
276
- var _a;
277
- super.release(), null === (_a = this._wordMeasureCache) || void 0 === _a || _a.clear(),
278
- this._wordMeasureCache = void 0;
267
+ this._fillingColorCallback && (this._fillingColorCallback = null);
279
268
  }
280
269
  }
281
270