diff --git a/README.md b/README.md index 288fef7..36fd0b5 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ for more detailed props, please refer to below: | data | The words array | `{ text: string, value: number }>[]` | ✓ | | width | Width of the layout (px) | `number` | | `700` | | height | Height of the layout (px) | `number` | | `600` | +| timeInterval | The maximum amount of time that can be spent during the current timestep (ms). Prevents the layout from getting stuck. | `number` | | `Infinity` | | font | The font accessor function, which indicates the font face for each word. A constant may be specified instead of a function. | `string \| (d) => string` | | `'serif'` | | fontStyle | The fontStyle accessor function, which indicates the font style for each word. A constant may be specified instead of a function. | `string \| (d) => string` | | `'normal'` | | fontWeight | The fontWeight accessor function, which indicates the font weight for each word. A constant may be specified instead of a function. | `string \| number \| (d) => string \| number` | | `'normal'` | diff --git a/src/WordCloud.tsx b/src/WordCloud.tsx index 5963d97..f00b870 100644 --- a/src/WordCloud.tsx +++ b/src/WordCloud.tsx @@ -20,6 +20,7 @@ type WordCloudProps = { data: Datum[]; width?: number; height?: number; + timeInterval?: number; font?: string | ((word: Word, index: number) => string); fontStyle?: string | ((word: Word, index: number) => string); fontWeight?: @@ -46,6 +47,7 @@ function WordCloud({ data, width = 700, height = 600, + timeInterval, font = 'serif', fontStyle = 'normal', fontWeight = 'normal', @@ -130,6 +132,10 @@ function WordCloud({ } }); + if (timeInterval) { + layout.timeInterval(timeInterval); + } + layout.start(); return el.toReact();