diff --git a/common/changes/@visactor/vchart/feat-optima-word-cloud-shape_2026-02-06-07-15.json b/common/changes/@visactor/vchart/feat-optima-word-cloud-shape_2026-02-06-07-15.json new file mode 100644 index 0000000000..83a66fdc8b --- /dev/null +++ b/common/changes/@visactor/vchart/feat-optima-word-cloud-shape_2026-02-06-07-15.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "feat: optimiz word-cloud-shape", + "type": "none", + "packageName": "@visactor/vchart" + } + ], + "packageName": "@visactor/vchart", + "email": "lixuef1313@163.com" +} \ No newline at end of file diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index f21971055a..e0be5eeed4 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -55,8 +55,8 @@ importers: specifier: 1.19.0-alpha.0 version: 1.19.0-alpha.0 '@visactor/vutils': - specifier: ~1.0.12 - version: 1.0.21 + specifier: ~1.0.22 + version: 1.0.22 axios: specifier: ^1.4.0 version: 1.13.2 @@ -209,8 +209,8 @@ importers: specifier: ~1.0.40 version: 1.0.40 '@visactor/vutils': - specifier: ~1.0.12 - version: 1.0.21 + specifier: ~1.0.22 + version: 1.0.22 react-is: specifier: ^18.2.0 version: 18.3.1 @@ -300,8 +300,8 @@ importers: specifier: ~1.0.40 version: 1.0.40 '@visactor/vutils': - specifier: ~1.0.12 - version: 1.0.21 + specifier: ~1.0.22 + version: 1.0.22 react-is: specifier: ^18.2.0 version: 18.3.1 @@ -523,11 +523,11 @@ importers: ../../packages/vchart: dependencies: '@visactor/vdataset': - specifier: ~1.0.12 - version: 1.0.21 + specifier: ~1.0.22 + version: 1.0.22 '@visactor/vlayouts': - specifier: ~1.0.12 - version: 1.0.21 + specifier: ~1.0.22 + version: 1.0.22 '@visactor/vrender-animate': specifier: ~1.0.40 version: 1.0.40 @@ -541,11 +541,11 @@ importers: specifier: ~1.0.40 version: 1.0.40 '@visactor/vscale': - specifier: ~1.0.12 - version: 1.0.21 + specifier: ~1.0.22 + version: 1.0.22 '@visactor/vutils': - specifier: ~1.0.12 - version: 1.0.21 + specifier: ~1.0.22 + version: 1.0.22 '@visactor/vutils-extension': specifier: workspace:2.0.15 version: link:../vutils-extension @@ -686,11 +686,11 @@ importers: specifier: workspace:2.0.15 version: link:../vchart '@visactor/vdataset': - specifier: ~1.0.12 - version: 1.0.21 + specifier: ~1.0.22 + version: 1.0.22 '@visactor/vlayouts': - specifier: ~1.0.12 - version: 1.0.21 + specifier: ~1.0.22 + version: 1.0.22 '@visactor/vrender-animate': specifier: ~1.0.40 version: 1.0.40 @@ -704,8 +704,8 @@ importers: specifier: ~1.0.40 version: 1.0.40 '@visactor/vutils': - specifier: ~1.0.12 - version: 1.0.21 + specifier: ~1.0.22 + version: 1.0.22 devDependencies: '@internal/bundler': specifier: workspace:* @@ -834,11 +834,11 @@ importers: ../../packages/vutils-extension: dependencies: '@visactor/vdataset': - specifier: ~1.0.12 - version: 1.0.21 + specifier: ~1.0.22 + version: 1.0.22 '@visactor/vutils': - specifier: ~1.0.12 - version: 1.0.21 + specifier: ~1.0.22 + version: 1.0.22 devDependencies: '@internal/bundler': specifier: workspace:* @@ -1269,8 +1269,8 @@ importers: specifier: ~1.0.40 version: 1.0.40 '@visactor/vutils': - specifier: ~1.0.12 - version: 1.0.21 + specifier: ~1.0.22 + version: 1.0.22 devDependencies: '@internal/bundler': specifier: workspace:* @@ -3061,11 +3061,11 @@ packages: '@visactor/vdataset@0.18.18': resolution: {integrity: sha512-lye23zpineMKV42JmuJaOY3fgl7aWhyDIwK9dWooqZzP14AFukPoK7ZvUeuKZihLrHxqtCg2VWEjovnh9O1RUg==} - '@visactor/vdataset@1.0.21': - resolution: {integrity: sha512-ZY1LFZsiZ3lHnDydQGoVJfuVAk6WWddSQXrWxFM4g+59OeByNJwLCf+46QtbJIjeRrJU7qgr+L2mlI4Mz3qeWQ==} + '@visactor/vdataset@1.0.22': + resolution: {integrity: sha512-B+Xd7UuXNNLWRsH0ySd9LsvFFBz/S+lFN7ha7GU7SdTYr9P0ZExYyumQPntaa5iOMLxKysFxJw7t/Or70ZA6hQ==} - '@visactor/vlayouts@1.0.21': - resolution: {integrity: sha512-PWHAU8nEMIW8VDRIfITqH1NtDAs3stQoWCVhhqMn0fs3MAn6FCzKrWNS6OHq8BYdN63NSQgQ8Q8hxQkwzoDndg==} + '@visactor/vlayouts@1.0.22': + resolution: {integrity: sha512-iTPJeROqmwBOBDoewDHYdEAe6MlDPgJ/1V1j+FcWr3zWGPDOSduoIDyjhB/FpkLaUQyhYCTCfCH3p2BDs3Wy4g==} '@visactor/vmind@1.2.4-alpha.5': resolution: {integrity: sha512-8Z/MFLN0bMLUMofurQ4175AHA5+Yln9CwA6ub1pMzsa+xTjGKALj3D7SseHUi4LSKSB3UGFwckqhKlKynrOfsA==} @@ -3100,8 +3100,8 @@ packages: '@visactor/vscale@0.18.18': resolution: {integrity: sha512-iRG4kv+5Fv4KX3AxEfV95XU3I6OmF0QizyAhqHxKa7L1MaT+MRvDDk5zHWf1E8gialLbL2xDe3GnT6g/4u5jhA==} - '@visactor/vscale@1.0.21': - resolution: {integrity: sha512-TIc5QyCfH/cvRMi6Mxi+D6KIUMIOfI9WsWidSKSCh3T1gNw2CdwiLLasayQyxqNdMbRjGzGV06A8g4TsjVHxEA==} + '@visactor/vscale@1.0.22': + resolution: {integrity: sha512-DCCqBA9gBZexCsfYmUjRZM1OBp2Qr8dRIGOqWcFerINIDtpQatSS4c8Ah2r8pqkgiizSNeKgDoXOtsiPe9zqBQ==} '@visactor/vscale@1.0.4': resolution: {integrity: sha512-mXuX0gbQ5dmsU+dOfrDfFT45ijTZrFh1wYeIY44cdMhFo4v+tVdeihN0F+3CEI7oSZiZENbpJ7dXvxnu04xG/g==} @@ -3130,8 +3130,8 @@ packages: '@visactor/vutils@0.19.7': resolution: {integrity: sha512-1SSnkZgX1p/rSVIFEibrpN6rDdLfdETSI6lJI5JwV8I2paluM1mqz3jEeT3McmWygd/wyUVKAyoRxGXFKAsKEw==} - '@visactor/vutils@1.0.21': - resolution: {integrity: sha512-mZ9pu53zI961RAwTBUd9BXpczE0Mk22zNX2x9ALX6iy0Uhlmw+vtewJiDWBeY73W+rVCHz7ziAKOVnv3LIo+Gw==} + '@visactor/vutils@1.0.22': + resolution: {integrity: sha512-n+lKEeSQl1wGqRG829oQ4SwU6UysUiP9rpp0K87TwmERVMupSy6C0KcM2SGXGBLvnp1Cyjjciw5ZtYQXv3ZfKQ==} '@visactor/vutils@1.0.4': resolution: {integrity: sha512-GE149SM5WAc9DMNV7bGtPD4xHP68vbHMRuxGPJ3ndzAGLC/KuXpClteMw6bTY1fRX1vDLY/tQ/GVthgeOx4kDw==} @@ -14977,12 +14977,12 @@ snapshots: simplify-geojson: 1.0.5 topojson-client: 3.1.0 - '@visactor/vdataset@1.0.21': + '@visactor/vdataset@1.0.22': dependencies: '@turf/flatten': 6.5.0 '@turf/helpers': 6.5.0 '@turf/rewind': 6.5.0 - '@visactor/vutils': 1.0.21 + '@visactor/vutils': 1.0.22 d3-dsv: 2.0.0 d3-geo: 1.12.1 d3-hexbin: 0.2.2 @@ -14997,12 +14997,12 @@ snapshots: simplify-geojson: 1.0.5 topojson-client: 3.1.0 - '@visactor/vlayouts@1.0.21': + '@visactor/vlayouts@1.0.22': dependencies: '@turf/helpers': 6.5.0 '@turf/invariant': 6.5.0 - '@visactor/vscale': 1.0.21 - '@visactor/vutils': 1.0.21 + '@visactor/vscale': 1.0.22 + '@visactor/vutils': 1.0.22 eventemitter3: 4.0.7 '@visactor/vmind@1.2.4-alpha.5': @@ -15029,7 +15029,7 @@ snapshots: '@visactor/vrender-animate@1.0.40': dependencies: '@visactor/vrender-core': 1.0.40 - '@visactor/vutils': 1.0.21 + '@visactor/vutils': 1.0.22 '@visactor/vrender-components@1.0.0-alpha.18': dependencies: @@ -15044,8 +15044,8 @@ snapshots: '@visactor/vrender-animate': 1.0.40 '@visactor/vrender-core': 1.0.40 '@visactor/vrender-kits': 1.0.40 - '@visactor/vscale': 1.0.21 - '@visactor/vutils': 1.0.21 + '@visactor/vscale': 1.0.22 + '@visactor/vutils': 1.0.22 '@visactor/vrender-core@1.0.0-alpha.18': dependencies: @@ -15054,7 +15054,7 @@ snapshots: '@visactor/vrender-core@1.0.40': dependencies: - '@visactor/vutils': 1.0.21 + '@visactor/vutils': 1.0.22 color-convert: 2.0.1 '@visactor/vrender-kits@1.0.0-alpha.18': @@ -15070,7 +15070,7 @@ snapshots: dependencies: '@resvg/resvg-js': 2.4.1 '@visactor/vrender-core': 1.0.40 - '@visactor/vutils': 1.0.21 + '@visactor/vutils': 1.0.22 gifuct-js: 2.1.2 lottie-web: 5.13.0 roughjs: 4.6.6 @@ -15086,9 +15086,9 @@ snapshots: dependencies: '@visactor/vutils': 0.18.18 - '@visactor/vscale@1.0.21': + '@visactor/vscale@1.0.22': dependencies: - '@visactor/vutils': 1.0.21 + '@visactor/vutils': 1.0.22 '@visactor/vscale@1.0.4': dependencies: @@ -15149,7 +15149,7 @@ snapshots: '@turf/invariant': 6.5.0 eventemitter3: 4.0.7 - '@visactor/vutils@1.0.21': + '@visactor/vutils@1.0.22': dependencies: '@turf/helpers': 6.5.0 '@turf/invariant': 6.5.0 diff --git a/docs/package.json b/docs/package.json index b783deb868..a6fd5a8ed3 100644 --- a/docs/package.json +++ b/docs/package.json @@ -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", diff --git a/packages/openinula-vchart/package.json b/packages/openinula-vchart/package.json index 2e58eea255..0f022edbd1 100644 --- a/packages/openinula-vchart/package.json +++ b/packages/openinula-vchart/package.json @@ -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" diff --git a/packages/react-vchart/package.json b/packages/react-vchart/package.json index 5ab7c45c67..08fa754e4f 100644 --- a/packages/react-vchart/package.json +++ b/packages/react-vchart/package.json @@ -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" diff --git a/packages/vchart-extension/package.json b/packages/vchart-extension/package.json index 0f8f37a9b2..4a32361a3e 100644 --- a/packages/vchart-extension/package.json +++ b/packages/vchart-extension/package.json @@ -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:*", diff --git a/packages/vchart/package.json b/packages/vchart/package.json index c9f2243a15..f0c1282b77 100644 --- a/packages/vchart/package.json +++ b/packages/vchart/package.json @@ -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", diff --git a/packages/vchart/src/series/word-cloud/base.ts b/packages/vchart/src/series/word-cloud/base.ts index cd05161160..c5371c0d58 100644 --- a/packages/vchart/src/series/word-cloud/base.ts +++ b/packages/vchart/src/series/word-cloud/base.ts @@ -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'; @@ -80,6 +81,8 @@ export class BaseWordCloudSeries { + this._wordMeasureCache?.clear(); this._dataChange = true; this.compile(); }); @@ -462,6 +470,7 @@ export class BaseWordCloudSeries(); + private _maxSize: number; + + constructor(maxSize: number = 1000) { + this._maxSize = maxSize; + } + + get(key: string) { + const v = this._map.get(key); + if (!v) { + return undefined; + } + + this._map.delete(key); + this._map.set(key, v); + + return v; + } + + set(key: string, value: CachedWordMeasure) { + if (this._map.has(key)) { + this._map.set(key, value); + return; + } + + if (this._map.size >= this._maxSize) { + const oldest = this._map.keys().next().value as string | undefined; + if (oldest !== undefined) { + this._map.delete(oldest); + } + } + + this._map.set(key, value); + } + + clear() { + this._map.clear(); + } + + size() { + return this._map.size; + } +} diff --git a/packages/vutils-extension/package.json b/packages/vutils-extension/package.json index 7252f6d95c..7f6ee63687 100644 --- a/packages/vutils-extension/package.json +++ b/packages/vutils-extension/package.json @@ -25,8 +25,8 @@ "test-watch": "DEBUG_MODE=1 jest --watch" }, "dependencies": { - "@visactor/vutils": "~1.0.12", - "@visactor/vdataset": "~1.0.12" + "@visactor/vutils": "~1.0.22", + "@visactor/vdataset": "~1.0.22" }, "devDependencies": { "@internal/bundler": "workspace:*", diff --git a/specs/optima-word-cloud-shape/plan.md b/specs/optima-word-cloud-shape/plan.md new file mode 100644 index 0000000000..64d64bbb86 --- /dev/null +++ b/specs/optima-word-cloud-shape/plan.md @@ -0,0 +1,12 @@ +# Implementation Plan: Optimize Word Cloud Shape + +## Summary +Feature: Optimize word cloud shape algorithm for better performance and layout. + +## Technical Context +**Branch**: `feat/optima-word-cloud-shape` + +## Source Code (repository root) +```text +packages/vchart/src/chart/word-cloud/ +``` diff --git a/tools/story-player/package.json b/tools/story-player/package.json index 4139c4509d..2586823aea 100644 --- a/tools/story-player/package.json +++ b/tools/story-player/package.json @@ -60,6 +60,6 @@ "@visactor/vrender-kits": "~1.0.40", "@visactor/vchart": "workspace:2.0.15", "@visactor/vrender": "~1.0.40", - "@visactor/vutils": "~1.0.12" + "@visactor/vutils": "~1.0.22" } }