-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwordcloud2.js
51 lines (45 loc) · 1.5 KB
/
wordcloud2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
HTMLWidgets.widget({
name: "wordcloud2",
type: "output",
initialize: function(el, width, height) {
var newCanvas = document.createElement("canvas");
newCanvas.height = height;
newCanvas.width = width;
newCanvas.id = "canvas";
el.appendChild(newCanvas);
newlabel(el);
return(el.firstChild);
},
renderValue: function(el, x, instance) {
// parse gexf data
listData=[];
for(var i=0; i<x.word.length; i++){
listData.push([x.word[i], x.freq[i]]);
}
if(x.figBase64){
maskInit(el,x);
}else{
WordCloud(el.firstChild, { list: listData,
fontFamily: x.fontFamily,
fontWeight: x.fontWeight,
color: x.color,
minSize: x.minSize,
weightFactor: x.weightFactor,
backgroundColor: x.backgroundColor,
gridSize: x.gridSize,
minRotation: x.minRotation,
maxRotation: x.maxRotation,
shuffle: x.shuffle,
shape: x.shape,
rotateRatio: x.rotateRatio,
ellipticity: x.ellipticity,
drawMask: x.drawMask,
maskColor: x.maskColor,
maskGapWidth: x.maskGapWidth,
hover: x.hover || cv_handleHover
});
}
},
resize: function(el, width, height) {
}
});