Skip to content

Commit

Permalink
feat: add customInsertZerosToArray in wordcloud #619
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed Jan 13, 2025
1 parent 1bb644c commit 47dca88
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vgrammar-core",
"comment": "feat: add customInsertZerosToArray in wordcloud #619",
"type": "none"
}
],
"packageName": "@visactor/vgrammar-core"
}
5 changes: 5 additions & 0 deletions packages/vgrammar-wordcloud/src/cloud-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ interface ICloudLayoutOptions extends IBaseLayoutOptions {

padding?: TagItemAttribute<number>;
enlarge?: boolean;

customInsertZerosToArray?: (array: any[], index: number, length: number) => void;
}

export class CloudLayout extends BaseLayout<ICloudLayoutOptions> implements IProgressiveTransformResult {
Expand Down Expand Up @@ -371,6 +373,9 @@ export class CloudLayout extends BaseLayout<ICloudLayoutOptions> implements IPro
// 分组扩充填充数组, 一次填充超过大概126000+会报stack overflow,worker环境下大概6w,这边取个比较小的
// https://stackoverflow.com/questions/22123769/rangeerror-maximum-call-stack-size-exceeded-why
private insertZerosToArray(array: any[], index: number, length: number) {
if (this.options.customInsertZerosToArray) {
return this.options.customInsertZerosToArray(array, index, length);
}
const len = Math.floor(length / MAX_ARGUMENTS_LENGTH);
const restLen = length % MAX_ARGUMENTS_LENGTH;

Expand Down

0 comments on commit 47dca88

Please sign in to comment.