Commit 1161937b authored by Mathieu Giraud's avatar Mathieu Giraud

merge -- less global variables, fix bugs with multiple scatterplots

Closes #2698 and contributes to #2201.
parents 9014e6cc 754f369c
Pipeline #10848 passed with stages
in 14 seconds
......@@ -64,14 +64,17 @@ Builder.prototype = {
this.build_clusterSelector()
this.initTag();
// if (this.m.samples.order.length == 1) this.resizeGraph(0)
if (this.m.samples.order.length == 1)
// One sample, two scatterplots
setTimeout(function() {
switch_visu2('scatterplot');
document.getElementById("visu2_mode_sp").checked = true;
})
else this.resizeGraph(50)
else
// Several samples, one graph and one scatterplot
setTimeout(function() {
switch_visu2('graph');
})
} catch (err) {
sendErrorToDb(err, this.db);
}
......
......@@ -214,7 +214,7 @@ Report.prototype = {
console.log(system_list);
this.m.wait("Generating report...")
this.switchstate(system_list, sample_list);
var current_system = sp.system;
var current_system = this.m.sp.system;
var self = this
this.w = window.open("report.html", "_blank", "selected=0, toolbar=yes, scrollbars=yes, resizable=yes");
......@@ -494,22 +494,22 @@ Report.prototype = {
if (typeof time != "undefined") this.m.changeTime(time)
this.m.changeGermline(system, false)
sp.changeSplitMethod(sp.AXIS_GENE_V, sp.AXIS_GENE_J, 'plot')
this.m.sp.changeSplitMethod(sp.AXIS_GENE_V, sp.AXIS_GENE_J, 'plot')
//resize 791px ~> 21cm
sp.resize(791,250)
sp.fastForward()
this.m.sp.resize(791,250)
this.m.sp.fastForward()
var w_sp = this.container(this.m.getStrTime(this.m.t, "short_name") + '' + system)
w_sp.addClass("scatterplot");
var svg_sp = document.getElementById(sp.id+"_svg").cloneNode(true);
var svg_sp = document.getElementById(this.m.sp.id+"_svg").cloneNode(true);
//set viewbox (same as resize)
svg_sp.setAttribute("viewBox","0 0 791 250");
for (var i = 0; i < this.m.clones.length; i++) {
var circle = svg_sp.querySelectorAll('[id="'+sp.id+'_circle'+i+'"]')[0]
var circle = svg_sp.querySelectorAll('[id="'+this.m.sp.id+'_circle'+i+'"]')[0]
var color = this.m.tag[this.m.clone(i).getTag()].color
circle.setAttribute("stroke", color);
......@@ -519,11 +519,11 @@ Report.prototype = {
}
}
var bar_container = svg_sp.querySelectorAll('[id="'+sp.id+'_bar_container"]')[0]
var bar_container = svg_sp.querySelectorAll('[id="'+this.m.sp.id+'_bar_container"]')[0]
bar_container.parentNode.removeChild(bar_container);
w_sp.append(svg_sp)
sp.resize();
this.m.sp.resize();
for (var j=0; j<this.list.length; j++){
var cloneID = this.list[j]
......
......@@ -188,11 +188,12 @@ function switch_visu2(view) {
if (view == "graph") {
m.view.push(graph);
tmp = graph;
builder.resizeGraph(50)
}
else if (view == "scatterplot") {
sp2 = new ScatterPlot("visu2", m, db);
sp2.default_preset = 5;
sp2 = new ScatterPlot("visu2", m, db, 5);
tmp = sp2;
builder.resizeGraph(40)
}
tmp.init();
......
......@@ -32,7 +32,7 @@
* @param {string} id - dom id of the html div who will contain the scatterplot
* @param {Model} model
* */
function ScatterPlot(id, model, database) {
function ScatterPlot(id, model, database, default_preset) {
var self = this;
View.call(this, model);
......@@ -146,7 +146,8 @@ function ScatterPlot(id, model, database) {
"number of deletions for the segment V/5 in 3" : { "mode": this.MODE_BAR, "x": "vDel", "y" : "size"},
"number of deletions for the segment J/3 in 5" : { "mode": this.MODE_BAR, "x": "jDel", "y" : "size"},
};
this.default_preset = 1
this.default_preset = (typeof default_preset == "undefined") ? 1 : default_preset ;
//Menu with graph distrib' (see initMenu function)
this.graph_menu = [
......@@ -160,7 +161,8 @@ function ScatterPlot(id, model, database) {
this.axisY.init(this.m.germlineJ, "J")
this.use_system_grid = false
this.m.sp = this
if (typeof this.m.sp == "undefined")
this.m.sp = this
}
......@@ -181,8 +183,7 @@ ScatterPlot.prototype = {
this.initMenu();
this.initSVG();
this.select_preset.selectedIndex = this.default_preset
this.changePreset();
this.setPreset(this.default_preset)
this.tsne_ready=false;
} catch(err) {
......@@ -1377,6 +1378,11 @@ ScatterPlot.prototype = {
this.m.update();
},
setPreset: function(preset){
this.select_preset.selectedIndex = preset
this.changePreset()
},
/**
* deactivate preset selection
*/
......
......@@ -80,14 +80,14 @@ Shortcut.prototype = {
// Preset shortcuts
if (! e.ctrlKey && ! e.metaKey &&
(((key >= 96) && (key <= 105)) || ((key >= 48) && (key <= 57))) ) { // Numeric keypad, 0-9
var select_preset = document.getElementsByClassName("axis_select_preset_select")[0]
var shift = 95;
if (key<58) shift = 47
if (e.shiftKey) shift -= 10
select_preset.selectedIndex = key - shift
var targetIndex = key - shift
console.log("setPreset: " + targetIndex)
try {
this.m.sp.changePreset(select_preset)
this.m.sp.setPreset(targetIndex)
}
catch (err) { } // There can be an error if the preset does not exist
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment