You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+6
Original file line number
Diff line number
Diff line change
@@ -79,3 +79,9 @@ Features supported:
79
79
- Various NLP methods (stopwords, ngrams)
80
80
- Wordcloud configurations
81
81
- Export/save/share wordclouds
82
+
83
+
## Donate
84
+
85
+
My projects will always be (ads-)free. I constantly learn from the community, so these projects are a way of giving back to the community. If you liked this project or find it useful, feel free to buy me a cup of coffee ☕️ through a small donation!
`ReactWordcloud` applies a limit that can be controlled by the `maxWords` prop. This is set to `100` by default. You can raise the limit but be careful that this could affect performance.
14
+
15
+
## Why is the most frequent word is not showing up?
16
+
17
+
This issue happens when the most frequent word is also the **longest** word. For a given wordcloud size, if the longest and most frequent word does not fit in the wordcloud SVG container, the `d3-cloud` algorithm drops them out. This is a known issue discussed in: https://github.com/jasondavies/d3-cloud/issues/36
18
+
19
+
`react-wordcloud` tries to solve this issue by recursively rendering the wordcloud if it detects that words have been dropped out. Each recursion would decrease the applied font-size by a scale factor. The recursion will bail out after some maximum attempts is reached, and a console warning will be thrown to the user informating that the words cannot be rendered in the wordcloud. The following example below demonstrates this scenario:
If you see this console warning, it is recommended that you address it in the following few common ways:
33
+
34
+
- Increase the wordcloud size (either using the `size` prop or the parent container).
35
+
- Reduce the `options.fontSizes` values.
36
+
- Avoid rendering long words at vertical angles (i.e. 90 degrees). Browser heights are more limited than widths, and the long words may not fit within the wordcloud height. You can control rotation angles using `rotationAngles` and `rotations` in the `options` props.
Copy file name to clipboardexpand all lines: docs/usage/options.mdx
+62-3
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,65 @@ import words from "./words";
12
12
13
13
You can customize many visual and layout properties of `ReactWordcloud` by using the `options` prop.
14
14
15
+
## Colors
16
+
17
+
`ReactWordcloud` will randomnly apply colors from an array of color hex codes.
18
+
19
+
<Playground>
20
+
<ReactWordcloud
21
+
options={{
22
+
colors: ["#1f77b4", "#9467bd", "#8c564b"]
23
+
}}
24
+
words={words}
25
+
/>
26
+
</Playground>
27
+
28
+
## Font Styles
29
+
30
+
Configure wordfont styles using the `fontFamily`, `fontSizes`, `fontStyle`, `fontWeight` options.
31
+
32
+
<Playground>
33
+
<ReactWordcloud
34
+
options={{
35
+
fontFamily: "courier new",
36
+
fontSizes: [10, 20],
37
+
fontStyle: "italic",
38
+
fontWeight: "bold"
39
+
}}
40
+
words={words}
41
+
/>
42
+
</Playground>
43
+
44
+
## Rotations
45
+
46
+
By default `ReactWordcloud` will apply random rotations if the `rotations` option is not specified. If `rotations` option is specified, it will use evenly-divided angles from the `rotationAngles` option based on the `rotations` value. The following example demonstrates using rotation angles of `0`, `45` and `90` degrees (i.e. `rotations = 3` and `rotationAngles=[0, 90]`).
47
+
48
+
<Playground>
49
+
<ReactWordcloud
50
+
options={{
51
+
rotations: 3,
52
+
rotationAngles: [0, 90]
53
+
}}
54
+
words={words}
55
+
/>
56
+
</Playground>
57
+
58
+
## Layout
59
+
60
+
Configure the wordcloud layout by using the `scale`, `spiral` options.
61
+
62
+
<Playground>
63
+
<ReactWordcloud
64
+
options={{
65
+
scale: "log",
66
+
spiral: "rectangular"
67
+
}}
68
+
words={words}
69
+
/>
70
+
</Playground>
71
+
72
+
## Interactive
73
+
15
74
Use the code editor to edit and play around with some of these options!
16
75
17
76
<Playground>
@@ -27,13 +86,13 @@ Use the code editor to edit and play around with some of these options!
// Recursively layout and decrease font-sizes by a SHRINK_FACTOR.
137
+
// Bail out with a warning message after MAX_LAYOUT_ATTEMPTS.
138
+
if(attempts===MAX_LAYOUT_ATTEMPTS){
139
+
console.warn(
140
+
`Unable to layout ${sortedWords.length-
141
+
computedWords.length} word(s) after ${attempts} attempts. Consider: (1) Increasing the container/component size. (2) Lowering the max font size. (3) Limiting the rotation angles.`,
0 commit comments