Sasha commited on
Commit
7347031
·
1 Parent(s): c2edfc7

fix: scale down word cloud rendering for low absolute frequency words

Browse files
Files changed (1) hide show
  1. client/src/App.jsx +5 -1
client/src/App.jsx CHANGED
@@ -1208,6 +1208,10 @@ export default function App() {
1208
  let fontSize;
1209
  let fontWeight;
1210
  let scaleValue = 0;
 
 
 
 
1211
 
1212
  if (isCenterGroup) {
1213
  // Scale font size within center group: ranges from 4.5rem to 6.2rem
@@ -1223,7 +1227,7 @@ export default function App() {
1223
  fontWeight = fontSize > 2.0 ? '700' : (fontSize > 1.4 ? '600' : '500');
1224
  }
1225
 
1226
- fontSize = fontSize * fontScale;
1227
 
1228
  // Precise width calculation based on custom width factors
1229
  const wordWidth = fontSize * getWordWidthFactor(w.word) * remToPx;
 
1208
  let fontSize;
1209
  let fontWeight;
1210
  let scaleValue = 0;
1211
+
1212
+ // Scale down the entire galaxy if the absolute max frequency is low (e.g. less than 200)
1213
+ // If maxCount is 20, galaxyScale is ~0.65. If 200+, it's 1.0.
1214
+ const galaxyScale = Math.min(Math.max(maxCount / 200, 0), 1.0) * 0.35 + 0.65;
1215
 
1216
  if (isCenterGroup) {
1217
  // Scale font size within center group: ranges from 4.5rem to 6.2rem
 
1227
  fontWeight = fontSize > 2.0 ? '700' : (fontSize > 1.4 ? '600' : '500');
1228
  }
1229
 
1230
+ fontSize = fontSize * fontScale * galaxyScale;
1231
 
1232
  // Precise width calculation based on custom width factors
1233
  const wordWidth = fontSize * getWordWidthFactor(w.word) * remToPx;