Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "feat: optimiz word-cloud-shape",
"type": "none",
"packageName": "@visactor/vchart"
}
],
"packageName": "@visactor/vchart",
"email": "lixuef1313@163.com"
}
94 changes: 47 additions & 47 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@visactor/vchart-extension": "workspace:2.0.15",
"@visactor/vchart-theme": "~1.6.6",
"@visactor/vmind": "1.2.4-alpha.5",
"@visactor/vutils": "~1.0.12",
"@visactor/vutils": "~1.0.22",
"@visactor/vrender": "~1.0.40",
"@visactor/vrender-kits": "~1.0.40",
"@visactor/vtable": "1.19.0-alpha.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/openinula-vchart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@visactor/vchart": "workspace:2.0.15",
"@visactor/vutils": "~1.0.12",
"@visactor/vutils": "~1.0.22",
"@visactor/vrender-core": "~1.0.40",
"@visactor/vrender-kits": "~1.0.40",
"react-is": "^18.2.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-vchart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@visactor/vchart": "workspace:2.0.15",
"@visactor/vchart-extension": "workspace:2.0.15",
"@visactor/vutils": "~1.0.12",
"@visactor/vutils": "~1.0.22",
"@visactor/vrender-core": "~1.0.40",
"@visactor/vrender-kits": "~1.0.40",
"react-is": "^18.2.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/vchart-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"@visactor/vrender-components": "~1.0.40",
"@visactor/vrender-animate": "~1.0.40",
"@visactor/vchart": "workspace:2.0.15",
"@visactor/vutils": "~1.0.12",
"@visactor/vdataset": "~1.0.12",
"@visactor/vlayouts": "~1.0.12"
"@visactor/vutils": "~1.0.22",
"@visactor/vdataset": "~1.0.22",
"@visactor/vlayouts": "~1.0.22"
},
"devDependencies": {
"@internal/bundler": "workspace:*",
Expand Down
8 changes: 4 additions & 4 deletions packages/vchart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@
"cross-env": "^7.0.3"
},
"dependencies": {
"@visactor/vutils": "~1.0.12",
"@visactor/vdataset": "~1.0.12",
"@visactor/vscale": "~1.0.12",
"@visactor/vlayouts": "~1.0.12",
"@visactor/vutils": "~1.0.22",
"@visactor/vdataset": "~1.0.22",
"@visactor/vscale": "~1.0.22",
"@visactor/vlayouts": "~1.0.22",
"@visactor/vrender-core": "~1.0.40",
"@visactor/vrender-kits": "~1.0.40",
"@visactor/vrender-components": "~1.0.40",
Expand Down
17 changes: 17 additions & 0 deletions packages/vchart/src/series/word-cloud/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import type {
WordCloudShapeConfigType,
WordCloudShapeType
} from './interface';
import { WordMeasureCache } from './measure-cache';
import type { Datum, IMarkSpec, IPoint, ITextMarkSpec } from '../../typings';
import { animationConfig, userAnimationConfig } from '../../animation/utils';
import { WORD_CLOUD_TEXT } from '../../constant/word-cloud';
Expand Down Expand Up @@ -80,6 +81,8 @@ export class BaseWordCloudSeries<T extends IBaseWordCloudSeriesSpec = IBaseWordC
protected _wordCloudConfig?: WordCloudConfigType;
protected _wordCloudShapeConfig?: WordCloudShapeConfigType;

private _wordMeasureCache?: WordMeasureCache;

protected _padding?: IPadding;
protected _defaultFontFamily: string;

Expand Down Expand Up @@ -133,6 +136,10 @@ export class BaseWordCloudSeries<T extends IBaseWordCloudSeriesSpec = IBaseWordC
!SHAPE_TYPE.includes(this._maskShape as string) &&
!['fast', 'grid', 'cloud'].includes(this._wordCloudConfig.layoutMode);
this._defaultFontFamily = this._option.getTheme('fontFamily') as string;

if (!this._wordMeasureCache) {
this._wordMeasureCache = new WordMeasureCache(1000);
}
}

/**
Expand All @@ -142,6 +149,7 @@ export class BaseWordCloudSeries<T extends IBaseWordCloudSeriesSpec = IBaseWordC
super.initData();
// data改变时, 需要重新编译, 重新布局
this.getViewData()?.target?.addListener('change', () => {
this._wordMeasureCache?.clear();
this._dataChange = true;
this.compile();
});
Expand Down Expand Up @@ -462,6 +470,7 @@ export class BaseWordCloudSeries<T extends IBaseWordCloudSeriesSpec = IBaseWordC
...wordCloudShapeConfig,
...this._getCommonTransformOptions(),
createImage,
measureCache: this._wordMeasureCache,

rotateList: this._rotateAngles,
fillingRotateList: wordCloudShapeConfig.fillingRotateAngles,
Expand Down Expand Up @@ -538,5 +547,13 @@ export class BaseWordCloudSeries<T extends IBaseWordCloudSeriesSpec = IBaseWordC
if (this._fillingColorCallback) {
this._fillingColorCallback = null;
}

this._wordMeasureCache?.clear();
}

release() {
super.release();
this._wordMeasureCache?.clear();
this._wordMeasureCache = undefined;
}
}
Loading
Loading