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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188 | /***************************************************************
* Copyright notice
*
* (c) 2014 PF bioinformatique de Toulouse
* All rights reserved
*
*
* This script is an adaptation of the venny script developed by
* Juan Carlos Oliveros, BioinfoGP, CNB-CSIC:
* Oliveros, J.C. (2007) VENNY. An interactive tool for comparing
* lists with Venn Diagrams.
* http://bioinfogp.cnb.csic.es/tools/venny/index.html.
* It is distributed under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/***************************************************************
*
* Adapted to Shiny by Franck Soubès.
*
****************************************************************/
$(document).ready(function () {
//$( "#jvenn-container-label1" ).draggable();
//$('#jvenn-container-label1').addClass('draggable');
var colorDefault = ["#FFA500", "#FFA500", "#FFA500", "#FFA500", "#FFA500", "#FFA500"],
displayMode = "classic",
displayStat = true,
displaySwitch= true,
shortNumber = true,
fontSize = "12px",
fontFamily = "Arial",
uploadSeries = new Array();
function updateJvenn() {
Shiny.addCustomMessageHandler("updatejvenn", function(Rjson) {
let seriesTable = Rjson; //jsonData;
Shiny.addCustomMessageHandler("updatejcol", function(coljvenn) {
let arraylen = (coljvenn.length/3);
let R2jspal =new Array(arraylen);
let mypalette = new Array(Math.ceil(coljvenn.length / 3)).fill("").map(function() { return this.splice(0, 3) }, coljvenn.slice());
for (let i = 0 ; i< arraylen ; i++ ){
R2jspal[i] = "rgb(".concat(mypalette[i]).concat(")");
}
$("#jvenn-container").jvenn({
series: seriesTable,
colors : R2jspal,
fontSize: fontSize,
fontFamily: fontFamily,
searchInput: $("#search-field"),
searchStatus: $("#search-status"),
displayMode: displayMode,
displayStat: displayStat,
displaySwitch:displaySwitch,
fnClickCallback: function() {
let value = "";
nameslis = [];
if (this.listnames.length == 1) {
value += "Elements only in ";
}
else {
value += "Common elements in ";
}
for (let name in this.listnames) {
nameslis.push(this.listnames[name]);
}
value += ":\n";
jvennlist =[];
for (let val in this.list) {
jvennlist.push( this.list[val]);
}
console.log(jvennlist);
$("#names").val(value);
Shiny.onInputChange("jvennlist",jvennlist);// renvoyer dans R
Shiny.onInputChange("together",nameslis.join(""));// renvoyer dans R
Shiny.onInputChange("selcontjv",nameslis);
return(jvennlist);
}
});
});
});
}
//$('.draggable').addClass('draggable');
//$('.draggable').draggable();
//$('#jvenn-container').addClass('parent');
//$('.children').draggable({ containment: "parent" });
//$('.children1').addClass('draggable');
//$('.children1').draggable();
//$("#jvenn-container" ).draggable();
//$('#jvenn-container').addClass('draggable');
//$("div#jvenn-container .test").addClass('draggable');
//$("div#jvenn-container .test").draggable();
$('.btn-group button').on('click', function(){
$(this).siblings().removeClass('active');
$(this).addClass('active');
});
$('[id^="clear"]').click(function() {
let index = $(this).attr("id").split("_")[1];
$("#area" + index).val("");
$("#name" + index).val("List " + index);
updateJvenn();
});
// update the view when any fields change
$("[id^=name]").change(function() {
updateJvenn();
});
$("[id^=area]").change(function() {
updateJvenn();
});
$("#venn-type").change(function() {
updateJvenn();
});
$("#ds_yes").click(function() {
displayStat = true;
Shiny.onInputChange("mystat",displayStat);
});
$("#ds_no").click(function() {
displayStat = false;
Shiny.onInputChange("mystat",displayStat);
});
$("#dsw_yes").click(function() {
displaySwitch = true;
Shiny.onInputChange("dispswitch",displaySwitch);
});
$("#dsw_no").click(function() {
displaySwitch = false;
Shiny.onInputChange("dispswitch",displaySwitch);
});
$("#dm_classic").click(function() {
displayMode = "classic";
Shiny.onInputChange("updamod",displayMode);
});
$("#dm_edwards").click(function() {
displayMode = "edwards";
Shiny.onInputChange("updamod",displayMode);
});
$('[id^="ff"]').click(function() {
fontFamily = $(this).html();
updateJvenn();
});
$('[id^="fs"]').click(function() {
fontSize = $(this).html();
Shiny.onInputChange("myfont",fontSize);
});
updateJvenn();
});
|