Skip to content

Commit 60d30bd

Browse files
authored
Merge pull request #381 from robertcv/fixes/word_cloud_size
[FIX] OWWordCloud: scale visualization
2 parents d9edda1 + ed1c6df commit 60d30bd

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

orangecontrib/text/widgets/owwordcloud.py

+17
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,23 @@ def on_cloud_pref_change(self):
169169
self.webview.evalJS('OPTIONS["minRotation"] = {}; \
170170
OPTIONS["maxRotation"] = {};'.format(-tilt_amount, tilt_amount))
171171
self.webview.evalJS('OPTIONS["rotateRatio"] = {};'.format(tilt_ratio))
172+
self.webview.evalJS('''
173+
OPTIONS["gridSize"] = function () {
174+
return Math.round(
175+
Math.min(
176+
document.getElementById("canvas").clientWidth,
177+
document.getElementById("canvas").clientHeight
178+
) / 48
179+
);
180+
};''')
181+
self.webview.evalJS('''
182+
OPTIONS["weightFactor"] = function (size) {
183+
return size *
184+
Math.min(
185+
document.getElementById("canvas").clientWidth,
186+
document.getElementById("canvas").clientHeight
187+
) / 512;
188+
};''')
172189
# Trigger cloud redrawing by constructing new webview, because everything else fail Macintosh
173190
self.webview.evalJS('OPTIONS["list"] = {};'.format(self.wordlist))
174191
self.webview.evalJS('redrawWordCloud();')

orangecontrib/text/widgets/resources/wordcloud2.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ if (!window.clearImmediate) {
312312
}
313313

314314
/* Make sure gridSize is a whole number and is not smaller than 4px */
315-
settings.gridSize = Math.max(Math.floor(settings.gridSize), 4);
315+
settings.gridSize = Math.max(Math.floor(settings.gridSize()), 4);
316316

317317
/* shorthand */
318318
var g = settings.gridSize;

0 commit comments

Comments
 (0)