Mercurial > repos > immport-devteam > flow_overview
comparison js/scatter2D.js @ 1:b5453d07f740 draft default tip
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flow_overview commit 65373effef15809f3db0e5f9603ef808f4110aa3"
author | azomics |
---|---|
date | Wed, 29 Jul 2020 17:03:53 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:8283ff163ba6 | 1:b5453d07f740 |
---|---|
1 // Copyright (c) 2016 Northrop Grumman. | |
2 // All rights reserved. | |
3 | |
4 var updateScatter2D = function(){ | |
5 scatterData2D['selectedPopulations'] = []; | |
6 scatterDataMFI['selectedPopulations'] = []; | |
7 $('.pop2D').each(function() { | |
8 if (this.checked) { | |
9 scatterData2D['selectedPopulations'].push(parseInt(this.value)); | |
10 scatterDataMFI['selectedPopulations'].push(parseInt(this.value)); | |
11 } | |
12 }); | |
13 processScatterData2D(); | |
14 processScatterDataMFI2D(); | |
15 displayScatterPlot2D(); | |
16 }; | |
17 | |
18 var processScatterData2D = function() { | |
19 var xData = [], | |
20 yData = [], | |
21 popData = [], | |
22 col1 = [], | |
23 col2 = [], | |
24 pop = [], | |
25 min = Number.MAX_VALUE, | |
26 max = Number.MIN_VALUE; | |
27 | |
28 min = d3.min(scatterData2D['data'], function(array) { | |
29 return d3.min(array); | |
30 }); | |
31 max = d3.max(scatterData2D['data'], function(array) { | |
32 return d3.max(array); | |
33 }); | |
34 scatterData2D['min'] = 0; | |
35 scatterData2D['max'] = max; | |
36 | |
37 col1 = scatterData2D['data'].map(function(value,index) { | |
38 return value[scatterData2D['m1']]; | |
39 }); | |
40 col2 = scatterData2D['data'].map(function(value,index) { | |
41 return value[scatterData2D['m2']]; | |
42 }); | |
43 pop = scatterData2D['data'].map(function(value,index) { | |
44 return value[scatterData2D['popCol']]; | |
45 }); | |
46 | |
47 for (var i = 0, j = col1.length; i < j; i++) { | |
48 if (scatterData2D['selectedPopulations'].indexOf(pop[i]) >= 0) { | |
49 xData.push(col1[i]); | |
50 yData.push(col2[i]); | |
51 popData.push(pop[i]); | |
52 } | |
53 } | |
54 | |
55 scatterData2D['popColors'] = popData.map(function(value,index) { | |
56 return color_palette[0][value][0]; | |
57 }); | |
58 scatterData2D['xData'] = xData; | |
59 scatterData2D['yData'] = yData; | |
60 scatterData2D['popData'] = popData; | |
61 return scatterData2D; | |
62 }; | |
63 | |
64 var displayScatterToolbar2D = function() { | |
65 $("#xAxisMarker2D").select2(); | |
66 $("#yAxisMarker2D").select2(); | |
67 $("#view2D").select2(); | |
68 | |
69 scatterData2D['columnHeadings'].map(function(value,index) { | |
70 $('#xAxisMarker2D') | |
71 .append($("<option></option>") | |
72 .attr("value",index) | |
73 .text(value)); | |
74 | |
75 $('#yAxisMarker2D') | |
76 .append($("<option></option>") | |
77 .attr("value",index) | |
78 .text(value)); | |
79 }); | |
80 | |
81 $('#xAxisMarker2D').select2("val",0); | |
82 $('#yAxisMarker2D').select2("val",1); | |
83 | |
84 $("#xAxisMarker2D").on("change",function(e) { | |
85 var m1 = $("#xAxisMarker2D").select2("val"); | |
86 scatterData2D['m1'] = m1; | |
87 scatterDataMFI['m1'] = m1; | |
88 updateScatter2D(); | |
89 }); | |
90 $("#yAxisMarker2D").on("change",function(e) { | |
91 var m2 = $("#yAxisMarker2D").select2("val"); | |
92 scatterData2D['m2'] = m2; | |
93 scatterDataMFI['m2'] = m2; | |
94 updateScatter2D(); | |
95 }); | |
96 $("#view2D").on("change",function(e) { | |
97 var view = $("#view2D").select2("val"); | |
98 scatterData2D['view'] = view; | |
99 updateScatter2D(); | |
100 }); | |
101 | |
102 $("#updateDisplay2D").on("click",function() { | |
103 $(".pop2D").prop("checked", true); | |
104 $("#selectall2D").prop('checked', true); | |
105 updateScatter2D(); | |
106 }); | |
107 }; | |
108 | |
109 var displayScatterPopulation2D = function() { | |
110 $('#populationTable2D tbody').empty(); | |
111 scatterData2D['populations'].map(function(value,index) { | |
112 $('#populationTable2D tbody') | |
113 .append('<tr><td align="center">' | |
114 + '<input type="checkbox" checked class="pop2D" value=' | |
115 + value + '/></td><td title="' + newNames[value] | |
116 + '">' + newNames[value] + '</td>' | |
117 + '<td><span style="background-color:' | |
118 + color_palette[0][value][0] + '">  </span></td>' | |
119 + '<td>' + scatterData2D['percent'][value - 1] + '</td></tr>'); | |
120 }); | |
121 | |
122 $('#selectall2D').click(function() { | |
123 var checkAll = $("#selectall2D").prop('checked'); | |
124 if (checkAll) { | |
125 $(".pop2D").prop("checked", true); | |
126 } else { | |
127 $(".pop2D").prop("checked", false); | |
128 } | |
129 updateScatter2D(); | |
130 }); | |
131 | |
132 $('.pop2D').click(function() { | |
133 if ($('.pop2D').length == $(".pop2D:checked").length) { | |
134 $('#selectall2D').prop("checked",true); | |
135 } else { | |
136 $('#selectall2D').prop("checked",false); | |
137 } | |
138 updateScatter2D(); | |
139 }); | |
140 | |
141 $('.pop2D').each(function() { | |
142 var selectedpop2D = parseInt(this.value); | |
143 if ($.inArray(selectedpop2D,scatterData2D['selectedPopulations']) > -1) { | |
144 this.checked = true; | |
145 } else { | |
146 this.checked = false; | |
147 } | |
148 }); | |
149 }; | |
150 | |
151 var displayScatterPlot2D = function() { | |
152 var h = $(window).height() - 200, | |
153 w = $("#scatterPlotDiv2D").width(), | |
154 xtitle = scatterData2D['columnHeadings'][scatterData2D['m1']], | |
155 ytitle = scatterData2D['columnHeadings'][scatterData2D['m2']], | |
156 view = scatterData2D['view'], | |
157 layout = {}, | |
158 traces = []; | |
159 | |
160 $("#scatterPlotDiv2D").empty(); | |
161 $("#scatterPlotDiv2D").height(h); | |
162 if ( view == 1 || view == 2) { | |
163 var trace1 = { | |
164 x: scatterData2D['xData'], | |
165 y: scatterData2D['yData'], | |
166 mode: 'markers', | |
167 opacity: .75, | |
168 hoverinfo: 'none', | |
169 marker: { | |
170 size: 2, | |
171 color: scatterData2D['popColors'] | |
172 }, | |
173 type: 'scatter' | |
174 }; | |
175 traces.push(trace1); | |
176 } | |
177 if ( view == 1 || view == 3) { | |
178 var trace2 = { | |
179 x: scatterDataMFI['xData'], | |
180 y: scatterDataMFI['yData'], | |
181 mode: 'markers', | |
182 opacity: 1.0, | |
183 hoverinfo: "x+y", | |
184 marker: { | |
185 symbol: 128, | |
186 size: 8, | |
187 color: scatterDataMFI['popColors'] | |
188 }, | |
189 type: 'scatter' | |
190 }; | |
191 traces.push(trace2); | |
192 } | |
193 | |
194 layout = { | |
195 title: '', | |
196 showlegend: false, | |
197 xaxis: { | |
198 range: [0,scatterData2D['max']], | |
199 title: xtitle | |
200 }, | |
201 yaxis: { | |
202 range: [0,scatterData2D['max']], | |
203 title: ytitle | |
204 } | |
205 }; | |
206 | |
207 Plotly.newPlot('scatterPlotDiv2D', traces, layout); | |
208 }; |