@visx/wordcloud

Word clouds are visual representations of text data in which each word's value is indicated by its font size or color.

Installation

npm install --save @visx/wordcloud

Examples

APIs

#<Wordcloud />

# heightnumberrequired

Height of the wordcloud layout.

# widthnumberrequired

Width of the wordcloud layout.

# wordsDatum[]required

Sets the words array.

# fontstring | ((datum: Datum, index: number) => string) | undefined

Sets the font accessor function, which indicates the font face for each word.

Default serif

# fontSizenumber | ((datum: Datum, index: number) => number) | undefined

Sets the fontSize accessor function, which indicates the numerical font size for each word.

Default function(datum) { return Math.sqrt(datum.value); }

# fontStylestring | ((datum: Datum, index: number) => string) | undefined

Sets the fontStyle accessor function, which indicates the font style for each word.

Default normal

# fontWeightstring | number | ((datum: Datum, index: number) => ReactText) | undefined

Sets the fontWeight accessor function, which indicates the font weight for each word.

Default normal

# paddingnumber | ((datum: Datum, index: number) => number) | undefined

Sets the padding accessor function, which indicates the numerical padding for each word.

Default 1

# random(() => number) | undefined

Sets the internal random number generator, used for selecting the initial position of each word, and the clockwise/counterclockwise direction of the spiral for each word. Random function should return a number in the range [0, 1). When the returned value is a fixed value, the layout coordinates of each word will be the same every time the word cloud of the same data is rendered. By default, the browser's built-in 'Math.random' is used, which means that each rendering will change the position of the word.

Default Math.random

# rotatenumber | ((datum: Datum, index: number) => number) | undefined

Sets the rotate accessor function, which indicates the rotation angle (in degrees) for each word.

Default function() { return (~~(Math.random() * 6) -3) * 30; }

# spiral"archimedean" | "rectangular" | ((size: [number, number]) => (t: number) => [number, number]) | undefined

Sets the current type of spiral used for positioning words. This can either be one of the two built-in spirals, "archimedean" and "rectangular", or an arbitrary spiral generator can be used.

Default archimedean